Exemple #1
0
 function User_xe17($id = '')
 {
     global $Config;
     parent::WikiUser($id);
     $cookie_id = $this->id != 'Anonymous' ? $this->id : '';
     // set xe_root_dir config option
     $xe_root_dir = !empty($Config['xe_root_dir']) ? $Config['xe_root_dir'] : dirname(__FILE__) . '/../../../xe';
     // default xe_root_dir is 'xe' subdirectory of the parent dir of the moniwiki
     $sessid = session_name();
     // PHPSESSID
     // set the session_id() using saved cookie
     if (isset($_COOKIE[$sessid])) {
         session_id($_COOKIE[$sessid]);
     }
     // do not use cookies for varnish cache server
     ini_set("session.use_cookies", 0);
     session_cache_limiter('');
     // Cache-Control manually for varnish cache
     session_start();
     // is it a valid user ?
     $udb = new UserDB($Config);
     $user = $udb->getUser($cookie_id);
     $update = false;
     if (!empty($cookie_id)) {
         // not found
         if ($user->id == 'Anonymous') {
             $this->setID('Anonymous');
             $update = true;
             $cookie_id = '';
         } else {
             // check ticket
             $ticket = getTicket($user->id, $_SERVER['REMOTE_ADDR']);
             if ($this->ticket != $ticket) {
                 // not a valid user
                 $this->ticket = '';
                 $this->setID('Anonymous');
                 $update = true;
                 //$cookie_id = '';
             } else {
                 // OK good user
                 $this->setID($cookie_id);
                 $id = $cookie_id;
                 $this->nick = $user->info['nick'];
                 $this->tz_offset = $user->info['tz_offset'];
                 $this->info = $user->info;
                 $this->ticket = $ticket;
             }
         }
     } else {
         // empty cookie
         $update = true;
     }
     if ($update && !empty($_SESSION['is_logged'])) {
         // init XE17, XE18
         define('__XE__', true);
         require_once $xe_root_dir . "/config/config.inc.php";
         $context =& Context::getInstance();
         $this->xe_context_init($context);
         // simplified init context method
         // $context->init(); // slow slow
         $oMemberModel =& getModel('member');
         $oMemberController =& getController('member');
         $oMemberController->setSessionInfo();
         $member = new memberModel();
         $xeinfo = $member->getLoggedInfo();
         $id = $xeinfo->user_id;
         $user = $udb->getUser($id);
         // get user info again
         // not a registered user ?
         if ($user->id == 'Anonymous' || $update || empty($user->info['nick'])) {
             // check groups
             $groups = array_keys($xeinfo->group_list);
             $wikigroups = array();
             $group_ok = $xeinfo->is_admin == 'Y' ? true : false;
             if (!empty($Config['xe_allowed_groups'])) {
                 $allowed_groups = $Config['xe_allowed_groups'];
                 for ($i = 0; $i < sizeof($groups); $i++) {
                     if (isset($allowed_groups[$groups[$i]])) {
                         $group_ok = true;
                         $groupname = $allowed_groups[$groups[$i]];
                         if (!empty($groupname)) {
                             $wikigroups[] = $groupname;
                         }
                     }
                 }
             } else {
                 $group_ok = true;
             }
             if ($group_ok) {
                 if (!empty($wikigroups)) {
                     $this->groups = $wikigroups;
                     $user->info['groups'] = implode(',', $wikigroups);
                     $this->info['groups'] = $user->info['groups'];
                 } else {
                     if (!empty($this->info['groups'])) {
                         $user->info['groups'] = '@User';
                         $this->info['groups'] = $user->info['groups'];
                     }
                 }
                 $this->setID($id);
                 // not found case
                 $this->info = $user->info;
                 // already registered case
                 $ticket = getTicket($id, $_SERVER['REMOTE_ADDR']);
                 // get ticket
                 if ($this->nick != $xeinfo->nick_name) {
                     $this->nick = $xeinfo->nick_name;
                     $this->info['nick'] = $xeinfo->nick_name;
                 }
                 if ($this->info['email'] == '') {
                     $this->info['email'] = $xeinfo->email_address;
                 }
                 $this->info['tz_offset'] = $this->tz_offset;
                 $this->ticket = $ticket;
             } else {
                 if (!empty($cookie_id)) {
                     header($this->unsetCookie());
                 }
                 $this->setID('Anonymous');
                 $id = 'Anonymous';
             }
         }
     } else {
         // not logged in
         if (empty($_SESSION['is_logged'])) {
             if (!empty($cookie_id)) {
                 header($this->unsetCookie());
             }
             $this->setID('Anonymous');
             $id = 'Anonymous';
         }
     }
     if ($update || !empty($id) and $id != 'Anonymous') {
         if ($cookie_id != $id) {
             header($this->setCookie());
         }
     }
     if ($update || !$udb->_exists($id)) {
         if (!$udb->_exists($id)) {
             if (!empty($Config['use_agreement']) && empty($this->info['join_agreement'])) {
                 $this->info['join_agreement'] = 'disagree';
             }
         }
         // automatically save/register user
         $dummy = $udb->saveUser($this);
     }
 }
Exemple #2
0
 function checkEmailConfirmation()
 {
     global $request;
     $wikidb = $request->getDbh();
     $data = $wikidb->get('ConfirmEmail');
     $id = $request->getArg('id');
     if (empty($data[$id])) {
         // id not found
         return HTML(HTML::h1("Confirm E-mail address"), HTML::h1("Sorry! Wrong URL"));
     }
     // upgrade the user
     $userid = $data['userid'];
     $email = $data['email'];
     $u = $request->getUser();
     if ($u->UserName() == $userid) {
         // lucky: current user (session)
         $prefs = $u->getPreferences();
         $request->_user->_level = WIKIAUTH_USER;
         $request->_prefs->set('emailVerified', true);
     } else {
         // not current user
         if (ENABLE_USER_NEW) {
             $u = WikiUser($userid);
             $u->getPreferences();
             $prefs =& $u->_prefs;
         } else {
             $u = new WikiUser($request, $userid);
             $prefs = $u->getPreferences();
         }
         $u->_level = WIKIAUTH_USER;
         $request->setUser($u);
         $request->_prefs->set('emailVerified', true);
     }
     unset($data[$id]);
     $wikidb->set('ConfirmEmail', $data);
     return HTML(HTML::h1("Confirm E-mail address"), HTML::p("Your e-mail address has now been confirmed."));
 }
Exemple #3
0
 function getPageChangeEmails($notify)
 {
     $emails = array();
     $userids = array();
     foreach ($notify as $page => $users) {
         if (glob_match($page, $this->_pagename)) {
             foreach ($users as $userid => $user) {
                 $um = UserManager::instance();
                 $dbUser = $um->getUserByUserName($userid);
                 $wiki = new Wiki($_REQUEST['group_id']);
                 $wp = new WikiPage($_REQUEST['group_id'], $_REQUEST['pagename']);
                 if ($dbUser && ($dbUser->isActive() || $dbUser->isRestricted()) && $wiki->isAutorized($dbUser->getId()) && $wp->isAutorized($dbUser->getId())) {
                     if (!$user) {
                         // handle the case for ModeratePage: no prefs, just userid's.
                         global $request;
                         $u = $request->getUser();
                         if ($u->UserName() == $userid) {
                             $prefs = $u->getPreferences();
                         } else {
                             // not current user
                             if (ENABLE_USER_NEW) {
                                 $u = WikiUser($userid);
                                 $u->getPreferences();
                                 $prefs =& $u->_prefs;
                             } else {
                                 $u = new WikiUser($GLOBALS['request'], $userid);
                                 $prefs = $u->getPreferences();
                             }
                         }
                         $emails[] = user_getemail_from_unix($userid);
                         $userids[] = $userid;
                     } else {
                         if (!empty($user['verified']) and !empty($user['email'])) {
                             $emails[] = user_getemail_from_unix($userid);
                             $userids[] = $userid;
                         } elseif (!empty($user['email'])) {
                             global $request;
                             // do a dynamic emailVerified check update
                             $u = $request->getUser();
                             if ($u->UserName() == $userid) {
                                 if ($request->_prefs->get('emailVerified')) {
                                     $emails[] = user_getemail_from_unix($userid);
                                     $userids[] = $userid;
                                     $notify[$page][$userid]['verified'] = 1;
                                     $request->_dbi->set('notify', $notify);
                                 }
                             } else {
                                 // not current user
                                 if (ENABLE_USER_NEW) {
                                     $u = WikiUser($userid);
                                     $u->getPreferences();
                                     $prefs =& $u->_prefs;
                                 } else {
                                     $u = new WikiUser($GLOBALS['request'], $userid);
                                     $prefs = $u->getPreferences();
                                 }
                                 if ($prefs->get('emailVerified')) {
                                     $emails[] = user_getemail_from_unix($userid);
                                     $userids[] = $userid;
                                     $notify[$page][$userid]['verified'] = 1;
                                     $request->_dbi->set('notify', $notify);
                                 }
                             }
                             // ignore verification
                             /*
                             if (DEBUG) {
                                 if (!in_array($user['email'],$emails))
                                     $emails[] = $user['email'];
                             }
                             */
                         }
                     }
                 }
             }
         }
     }
     $emails = array_unique($emails);
     $userids = array_unique($userids);
     return array($emails, $userids);
 }
 function _do_email_verification(&$request, &$args)
 {
     $dbi = $request->getDbh();
     $pagelist = new PageList('pagename', 0, $args);
     //$args['return_url'] = 'action=email-verification-verified';
     $email = new _PageList_Column_email('email', _("E-Mail"), 'left');
     $emailVerified = new _PageList_Column_emailVerified('emailVerified', _("Verification Status"), 'center');
     $pagelist->_columns[] = $email;
     $pagelist->_columns[] = $emailVerified;
     //This is the best method to find all users (Db and PersonalPage)
     $current_user = $request->_user;
     if (empty($args['verify'])) {
         $group = $request->getGroup();
         $allusers = $group->_allUsers();
     } else {
         $allusers = array_keys($args['user']);
     }
     foreach ($allusers as $username) {
         if (ENABLE_USER_NEW) {
             $user = WikiUser($username);
         } else {
             $user = new WikiUser($request, $username);
         }
         $prefs = $user->getPreferences();
         if ($prefs->get('email')) {
             if (!$prefs->get('userid')) {
                 $prefs->set('userid', $username);
             }
             if (!empty($pagelist->_rows)) {
                 $group = (int) (count($pagelist->_rows) / $pagelist->_group_rows);
             } else {
                 $group = 0;
             }
             $class = $group % 2 ? 'oddrow' : 'evenrow';
             $row = HTML::tr(array('class' => $class));
             $page_handle = $dbi->getPage($username);
             $row->pushContent($pagelist->_columns[0]->format($pagelist, $page_handle, $page_handle));
             $row->pushContent($email->format($pagelist, $prefs, $page_handle));
             if (!empty($args['verify'])) {
                 $prefs->_prefs['email']->set('emailVerified', empty($args['verified'][$username]) ? 0 : 2);
                 $user->setPreferences($prefs);
             }
             $row->pushContent($emailVerified->format($pagelist, $prefs, $args['verify']));
             $pagelist->_rows[] = $row;
         }
     }
     $request->_user = $current_user;
     if (!empty($args['verify'])) {
         return HTML($pagelist->_generateTable(false));
     } else {
         $args['verify'] = 1;
         $args['return_url'] = $request->getURLtoSelf();
         return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HiddenInputs($args, 'wikiadminutils'), HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)), HiddenInputs($request->getArgs()), $pagelist->_generateTable(false), HTML::p(Button('submit:', _("Change Verification Status"), 'wikiadmin'), HTML::Raw('&nbsp;'), Button('cancel', _("Cancel"))));
     }
 }
Exemple #5
0
 function getPageChangeEmails($notify)
 {
     $emails = array();
     $userids = array();
     foreach ($notify as $page => $users) {
         if (glob_match($page, $this->_pagename)) {
             foreach ($users as $userid => $user) {
                 if (!$user) {
                     // handle the case for ModeratePage: no prefs, just userid's.
                     global $request;
                     $u = $request->getUser();
                     if ($u->UserName() == $userid) {
                         $prefs = $u->getPreferences();
                     } else {
                         // not current user
                         if (ENABLE_USER_NEW) {
                             $u = WikiUser($userid);
                             $u->getPreferences();
                             $prefs =& $u->_prefs;
                         } else {
                             $u = new WikiUser($GLOBALS['request'], $userid);
                             $prefs = $u->getPreferences();
                         }
                     }
                     $emails[] = $prefs->get('email');
                     $userids[] = $userid;
                 } else {
                     if (!empty($user['verified']) and !empty($user['email'])) {
                         $emails[] = $user['email'];
                         $userids[] = $userid;
                     } elseif (!empty($user['email'])) {
                         global $request;
                         // do a dynamic emailVerified check update
                         $u = $request->getUser();
                         if ($u->UserName() == $userid) {
                             if ($request->_prefs->get('emailVerified')) {
                                 $emails[] = $user['email'];
                                 $userids[] = $userid;
                                 $notify[$page][$userid]['verified'] = 1;
                                 $request->_dbi->set('notify', $notify);
                             }
                         } else {
                             // not current user
                             if (ENABLE_USER_NEW) {
                                 $u = WikiUser($userid);
                                 $u->getPreferences();
                                 $prefs =& $u->_prefs;
                             } else {
                                 $u = new WikiUser($GLOBALS['request'], $userid);
                                 $prefs = $u->getPreferences();
                             }
                             if ($prefs->get('emailVerified')) {
                                 $emails[] = $user['email'];
                                 $userids[] = $userid;
                                 $notify[$page][$userid]['verified'] = 1;
                                 $request->_dbi->set('notify', $notify);
                             }
                         }
                         // ignore verification
                         /*
                         if (DEBUG) {
                             if (!in_array($user['email'],$emails))
                                 $emails[] = $user['email'];
                         }
                         */
                     }
                 }
             }
         }
     }
     $emails = array_unique($emails);
     $userids = array_unique($userids);
     return array($emails, $userids);
 }
Exemple #6
0
 function User_g4($id = '')
 {
     global $DBInfo;
     global $g4, $member, $g4_root_dir;
     parent::WikiUser($id);
     if ($this->id == 'Anonymous') {
         return;
     }
     $cookie_id = $this->id;
     // setup GnuBoard
     $g4_root_dir = !empty($DBInfo->g4_root_dir) ? $DBInfo->g4_root_dir : __DIR__ . '/../../../gb4';
     $g4_root_url = !empty($DBInfo->g4_root_url) ? $DBInfo->g4_root_url : '/gb4';
     $g5_path = array();
     $g5_path['path'] = realpath($g4_root_dir);
     $g5_path['url'] = $g4_root_url;
     include_once "{$g4_root_dir}/config.php";
     // g4 config file
     ini_set("url_rewriter.tags", "");
     // session settings
     session_save_path("{$g4_root_dir}/data/session");
     ini_set("session.use_trans_sid", 1);
     // default
     //ini_set("session.cache_expire", 180); //default
     //ini_set("session.gc_probability", 1); // default
     //ini_set("session.gc_divisor", 100); // default
     session_set_cookie_params(0, "/");
     if (defined('G5_VERSION')) {
         ini_set("session.cookie_domain", G5_COOKIE_DOMAIN);
     } else {
         ini_set("session.cookie_domain", $g4['cookie_domain']);
     }
     // do not use cookies for varnish cache server
     ini_set("session.use_cookies", 0);
     // set the session_id() using saved cookie
     if (isset($_COOKIE['PHPSESSID'])) {
         session_id($_COOKIE['PHPSESSID']);
     }
     session_cache_limiter('');
     // Cache-Control manually for varnish cachie
     session_start();
     $udb = new UserDB($DBInfo);
     $user = $udb->getUser($cookie_id);
     $update = false;
     if (!empty($cookie_id)) {
         // not found
         if ($user->id == 'Anonymous') {
             $this->setID('Anonymous');
             $update = true;
             $cookie_id = '';
         } else {
             // check ticket
             $ticket = getTicket($user->id, $_SERVER['REMOTE_ADDR']);
             if ($this->ticket != $ticket) {
                 // not a valid user
                 $this->ticket = '';
                 $this->setID('Anonymous');
                 $update = true;
                 $cookie_id = '';
             } else {
                 // OK good user
                 $this->setID($cookie_id);
                 $id = $cookie_id;
                 $this->nick = $user->info['nick'];
                 $this->tz_offset = $user->info['tz_offset'];
                 $this->info = $user->info;
             }
         }
     } else {
         $update = true;
     }
     if ($update && !empty($_SESSION['ss_mb_id'])) {
         // init G4
         $this->g4_init();
         if (!empty($member['mb_id'])) {
             $id = $member['mb_id'];
             $user = $udb->getUser($id);
             // get user info again
             // not a registered user ?
             if ($user->id == 'Anonymous' || $update || empty($user->info['nick'])) {
                 $this->setID($id);
                 // not found case
                 $this->info = $user->info;
                 // already registered case
                 if (isset($member['mb_nick']) and $this->nick != $member['mb_nick']) {
                     // G4
                     $this->info['nick'] = $member['mb_nick'];
                     $this->nick = $member['mb_nick'];
                 } else {
                     if (isset($member['nick']) and $this->nick != $member['nick']) {
                         // G5
                         $this->info['nick'] = $member['nick'];
                         $this->nick = $member['nick'];
                     }
                 }
                 if ($this->info['email'] == '') {
                     $this->info['email'] = $member['mb_email'];
                 }
                 $this->info['tz_offset'] = $this->tz_offset;
             }
         }
     } else {
         // not logged in
         if (empty($_SESSION['ss_mb_id'])) {
             if (!empty($cookie_id)) {
                 header($this->unsetCookie());
             }
             $this->setID('Anonymous');
             $id = 'Anonymous';
         }
     }
     // update timezone
     if ($this->tz_offset != $user->info['tz_offset']) {
         $this->info['tz_offset'] = $this->tz_offset;
         $update = true;
     }
     if ($update || !empty($id) and $id != 'Anonymous') {
         if ($cookie_id != $id) {
             header($this->setCookie());
         }
     }
     if ($update || !$udb->_exists($id)) {
         if (!$udb->_exists($id)) {
             if (!empty($DBInfo->use_agreement) && empty($this->info['join_agreement'])) {
                 $this->info['join_agreement'] = 'disagree';
             }
         }
         // automatically save/register user
         $dummy = $udb->saveUser($this);
     }
 }