protected function joinTeam(user $user) { global $tmpl; // perform sanity checks if (($result = $this->sanityCheck()) !== true) { $tmpl->assign('error', $result === false ? 'An unknown error occurred while checking your request' : $result); return; } // join team if (!$this->user->addTeamMembership($this->team->getID()) || !$this->user->update()) { $tmpl->assign('error', 'An unknown error occurred while joining the team.'); } else { // notify team members using a private message $pm = new pm(); $pm->setSubject($user->getName() . ' joined your team'); $pm->setContent('Congratulations, ' . $user->getName() . ' just joined your team.'); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addTeamID($this->team->getID()); // send it $pm->send(); // tell joined user that join was successful $tmpl->assign('teamJoinSuccessful', true); } }
public function toDoList() { // ToDo-list if (isset($this->user)) { $newmsgs = 0; $msgs = new pm(); $msgs->recipient_id = $this->user->id; $msgs->recipient_delete = 0; $msgs->is_read = 0; if ($msgs->find()) { while ($msgs->fetch()) { ++$newmsgs; } } $wait_res_count = 0; $waiting_res = $this->user->getWaitingRes(); if (is_array($waiting_res)) { foreach ($waiting_res as $res) { ++$wait_res_count; } } $waiting_user = new poolsUser(); $wait_user_count = array(); $waiting_user->wait = 1; $wait_user = false; if ($waiting_user->find()) { while ($waiting_user->fetch()) { $user_admin = new poolsAdmin(); $user_admin->pool_id = $waiting_user->pool_id; $user_admin->user_id = $this->user->id; if ($user_admin->find()) { $wait_user = true; ++$wait_user_count["{$waiting_user->pool_id}"]["count"]; $wait_user_count["{$waiting_user->pool_id}"]["pool"] = new pools(); $wait_user_count["{$waiting_user->pool_id}"]["pool"]->get($waiting_user->pool_id); } } } if ($wait_user || $wait_res_count > 0 || $newmsgs > 0) { $todo = array(); if ($wait_res_count > 0) { $todo['res'] = $wait_res_count; } if ($newmsgs > 0) { $todo['msgs'] = $newmsgs; } if ($wait_user) { $todo['user'] = $wait_user_count; } $this->todo = $todo; } else { $this->todo = false; } } }
/* * This file is part of Paradise-Bird-Project. * Paradise-Bird-Project is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * Paradise-Bird-Project 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 General Public License for more details. * You should have received a copy of the GNU General Public License * along with Paradise-Bird-Project. If not, see <http://www.gnu.org/licenses/>. */ error_reporting(E_ALL); require_once "pm/include/pm.class.php"; global $pm; $pm = new pm(); if (isset($_GET['p'])) { if (!$pm->openIndex($_GET['p'])) { $pm->showError('404', 404); } } else { if (!$pm->openIndex('index')) { $pm->showError('404', 404); } } echo $pm->getTpl(); //if(isset($_GET['action']) && $_GET['action'] == 'save' && isset($_GET['package'])){ // $return = $pm->saveForm($_GET['package']); //} //$pm->cfgFormOut(false, 'index');
protected function reactivateTeam() { global $tmpl; // perform sanity checks if (($result = $this->sanityCheck()) !== true) { $tmpl->assign('error', $result === false ? 'An unknown error occurred while checking your request' : $result); return; } $tmpl->assign('teamName', $this->team->getName()); $tmpl->assign('teamid', $this->team->getID()); $tmpl->assign('userName', $this->user->getName()); $tmpl->assign('userid', $this->user->getID()); // reactivate team with chosen leader // issue an invitation for team leader so he can join $invitation = new invitation(); $invitation->forUserId($this->user->getID()); $invitation->toTeam($this->team->getID()); $invitation->insert(false); // now change team status to reactivate and add the user to team then make the user leader if (!$this->team->setStatus('reactivated') || !$this->team->update() || !$this->user->addTeamMembership($this->team->getID()) || !$this->user->update() || !$this->team->setLeaderId($this->user->getID()) || !$this->team->update()) { /* var_dump($this->user->addTeamMembership($this->team->getID())); */ $tmpl->assign('error', 'An unknown error occurred while reactivating the team.'); } else { // notify team members using a private message $pm = new pm(); $pm->setSubject(\user::getCurrentUser()->getName() . ' reactivated team ' . $this->team->getName()); $pm->setContent('Congratulations: Player ' . \user::getCurrentUser()->getName() . ' reactivated team ' . $this->team->getName() . ' with you as its leader.'); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addUserID($this->user->getID()); // send it $pm->send(); // tell user that team reactivation was successful $tmpl->assign('teamReactivationSuccessful', true); } }
protected function leaveTeam() { global $tmpl; // perform sanity checks if (($result = $this->sanityCheck()) !== true) { $tmpl->assign('error', $result === false ? 'An unknown error occurred while checking your request' : $result); } // remove user from team if (!$this->user->removeTeamMembership($this->team->getID()) || !$this->user->update()) { $tmpl->assign('error', 'An unknown error occurred while leaving the team.'); } else { // notify team members using a private message $pm = new pm(); if (\user::getCurrentUserId() === $this->user->getID()) { // notify team members about left member $pm->setSubject($this->user->getName() . ' left your team'); $pm->setContent('Player ' . $this->user->getName() . ' just left your team.'); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addTeamID($this->team->getID()); // send it $pm->send(); } else { // notify team members of kicked member $pm->setSubject($this->user->getName() . ' got kicked from your team'); $pm->setContent('Player ' . $this->user->getName() . ' got kicked from your team by ' . \user::getCurrentUser()->getName() . '.'); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addTeamID($this->team->getID()); // send it $pm->send(); // notify kicked member of the kick $pm = new pm(); $pm->setSubject('You got kicked from your team by ' . \user::getCurrentUser()->getName()); $pm->setContent('Player ' . \user::getCurrentUser()->getName() . ' just kicked you from your team.'); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addUserID($this->user->getID()); // send it $pm->send(); } // tell joined user that join was successful $tmpl->assign('teamLeaveSuccessful', true); } }
public $content; public function __construct() { exec('cat ./json.data', $result); $this->content = count($result) > 0 ? $result[0] : "get data error"; } public function show() { echo $this->content; } } ?> <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $pm = new pm(); $pm->show(); } else { ?> <html> <head> <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script> </head> <title>乐居气象监测站</title> <link rel="icon" href="favicon.ico"> <style> div {font-size:15px; line-height:20px;} #time {margin-top:20px;} </style> <body> <h3>室内:</h3>
protected function deleteTeam() { global $site; global $tmpl; // perform sanity checks if (($result = $this->sanityCheck()) !== true) { $tmpl->assign('error', $result === false ? 'An unknown error occurred while checking your request' : $result); return; } // notify team members using a private message first because later we won't have the membership info $pm = new pm(); $pm->setSubject(\user::getCurrentUser()->getName() . ' deleted ' . $this->team->getName()); $pm->setContent('Player ' . \user::getCurrentUser()->getName() . ' just deleted the team ' . $this->team->getName() . ' you were member of.'); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addTeamID($this->team->getID()); // send it $pm->send(); // remove the members from team $members = $this->team->getUsers(); foreach ($members as $member) { $member->removeTeamMembership($this->team->getID()); $member->update(); } unset($members); unset($member); // if team never matched deleted it from database, otherwise just mark it as deleted require_once $site->installationPath() . '/CMS/classes/match.php'; $matchCount = \match::getMatchCountForTeamId($this->team->getID()); if ($matchCount > 0 || $matchCount === false) { // set the teams status to deleted $this->team->setStatus('deleted'); $deletionTask = $this->team->update(); } else { // actually delete team $deletionTask = $this->team->delete(); } if (!$deletionTask) { $tmpl->assign('error', 'An unknown error occurred while deleting the team.'); } else { // tell joined user that deletion was successful $tmpl->assign('teamDeleteSuccessful', true); } }
public static function sendWelcomeMessage($id) { global $config; $subject = $config->getValue('login.welcome.subject') ? $config->getValue('login.welcome.subject') : 'Welcome'; $content = $config->getValue('login.welcome.content') ? $config->getValue('login.welcome.content') : 'Welcome and thanks for registering at this website!' . "\n" . 'In the FAQ you can find the most important informations' . ' about organising and playing matches.' . "\n\n" . 'See you on the battlefield.'; // prepare welcome message $pm = new pm(); $pm->setSubject($subject); $pm->setContent($content); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addUserID($id); // send it $pm->send(); }
private function process() { $mail = services::getService('mail'); $config = services::getService('config'); $lang = services::getService('lang'); $params = services::getService('pageParams'); $categories = services::getService('cats'); // function is set if ($params->getParam('function')) { $this->function = $params->getParam('function'); } else { $this->function = 'inbox'; } // view if ($this->function == 'view') { $view = new pm(); $view->id = $params->getParam('msg_id'); $view->find(true); if ($view->recipient_id == $this->user->id || $view->sender_id == $this->user->id) { if ($view->recipient_id == $this->user->id) { $view->fetchSender(); $delete = clone $view; $delete->delete(); $view->is_read = 1; $view->insert(); } if ($view->sender_id == $this->user->id) { $view->fetchRecipient(); } $this->view = clone $view; } } // inbox if ($this->function == 'inbox') { // delete if ($params->getParam('delete')) { $msg = new pm(); $msg->id = $params->getParam('delete'); $msg->find(); $msg->fetch(); if ($msg->recipient_id == $this->user->id) { $delete = clone $msg; $delete->delete(); $msg->recipient_delete = 1; $msg->insert(); $this->addMsg('msg_msg_deleted'); } } // mark read if ($params->getParam('markread')) { $msg = new pm(); $msg->id = $params->getParam('markread'); $msg->find(); $msg->fetch(); if ($msg->recipient_id == $this->user->id) { $delete = clone $msg; $delete->delete(); $msg->is_read = 1; $msg->insert(); } } // get list $msgs = new pm(); $msgs->recipient_id = $this->user->id; $msgs->recipient_delete = 0; $msgs->orderBy('is_read ASC, date DESC'); $msgs->find(); while ($msgs->fetch()) { $msgs->fetchSender(); $this->inbox[] = clone $msgs; } } // sent if ($this->function == 'sent') { $msgs = new pm(); $msgs->sender_id = $this->user->id; $msgs->orderBy('date DESC'); $msgs->find(); while ($msgs->fetch()) { $msgs->fetchRecipient(); $this->sent[] = clone $msgs; } } if ($this->function == 'new') { if ($params->getParam('recipient')) { $this->msgform = new formPM('msgform', $params->getParam('recipient')); $recipient = new user(); $recipient->id = $params->getParam('recipient'); $recipient->find(true); $this->recipient = clone $recipient; if ($params->getParam('answer')) { $answer = new pm(); $answer->id = $params->getParam('answer'); $answer->find(true); $this->msgform->setDefaults(array('title' => 'Re: ' . $answer->title)); } if ($this->msgform->validate()) { $msg = new pm(); $msg->recipient_id = $this->msgform->exportValue('recipient'); $msg->sender_id = $this->user->id; $msg->title = $this->msgform->exportValue('title'); $msg->body = $this->msgform->exportValue('body'); $msg->is_in_draft = 0; $msg->is_read = 0; $msg->recipient_delete = 0; $msg->sender_delete = 0; $msg->date = time(); $msg->insert(); $addr = new adressbook(); $addr->recipient_id = $this->msgform->exportValue('recipient'); $addr->sender_id = $this->user->id; if (!$addr->find()) { $addr->insert(); } // send email $recipient = new user(); $recipient->id = $this->msgform->exportValue('recipient'); $recipient->find(true); $mail->send('new_pm', $recipient, $this->user); $this->switchPage('pm&function=inbox&msg=msg_msg_sent'); } } else { if ($params->getParam('delete')) { $delete = new adressbook(); $delete->sender_id = $this->user->id; $delete->recipient_id = $params->getParam('delete'); $delete->delete(); $this->addMsg('msg_contact_deleted'); } $addr = new adressbook(); $addr->sender_id = $this->user->id; $addr->find(); while ($addr->fetch()) { $addr->fetchRecipient(); $this->adressbook[] = clone $addr; } } } $this->commonProcess(); }
public function insert($sendPM = true) { global $db; if (count($this->teamids) > 0) { foreach ($this->teamids as $teamid) { if (count($this->userids) > 0) { $query = $db->prepare('INSERT INTO `invitations` (`userid`, `teamid`, `expiration`) VALUES (:userid, :teamid, :expiration)'); foreach ($this->userids as $userid) { if (!$db->execute($query, array(':userid' => array((int) $userid, PDO::PARAM_INT), ':teamid' => array((int) $teamid, PDO::PARAM_INT), ':expiration' => array(strftime('%Y-%m-%d %H:%M:%S', $this->expiration), PDO::PARAM_STR)))) { return false; } if ($sendPM) { $pm = new pm(); $pm->setSubject(\user::getCurrentUser()->getName() . ' invited you to ' . (new team($teamid))->getName()); $pm->setContent('Congratulations: ' . \user::getCurrentUser()->getName() . ' invited you to ' . (new team($teamid))->getName() . '. The invitation is valid until ' . strftime('%Y-%m-%d %H:%M:%S', $this->expiration) . '.'); $pm->setTimestamp(date('Y-m-d H:i:s')); $pm->addUserID($userid); // send it $pm->send(); } } } } } return true; }
private function doLogin($moduleInstance, $moduleName) { global $config; // if used login module is not local, then an external login has been used $externalLogin = strcasecmp($moduleName, 'local') !== 0; // init user id to reserved value 0 $uid = 0; // load operations framework include dirname(__FILE__) . '/classes/userOperations.php'; $userOperations = new userOperations(); if ($externalLogin) { // lookup internal id using external id $uid = \user::getIdByExternalId($moduleInstance->getID()); } else { // local login id is equal to internal login id by definition $uid = $moduleInstance->getID(); } // if uid is 0 this means // either new user // or user already registered using local login if ($uid === 0) { if ($externalLogin) { // try to recover uid by username based db lookup $uid_list = \user::getIdByName($moduleInstance->getName()); // iterate through the list, trying to update old callsigns // and hoping to find the proper user account for this login attempt foreach ($uid_list as $one_uid) { // check external login id for match with external login module id // $moduleInstance->getID() must have a valid value if login got approved // by the external login module used $user = new \user($one_uid); $servicematch = false; foreach ($user->getExternalIds as $eservice) { // only act on matching service type if ($eservice->service === $moduleInstance->getType) { $servicematch = true; if ($eservice->euid !== $moduleInstance->getID()) { // try to resolve the name conflict by updating a username that might be forgotten $userOperations->updateUserName($one_uid, $eservice->euid, $moduleInstance->getName()); } else { $uid = $one_uid; break; } } } if (!$servicematch) { $uid = $one_uid; } } unset($servicematch); unset($eservice); unset($uid_list); unset($one_uid); } // init newUser to false (do not send welcome message by default) $newUser = false; // find out if an internal id can be found for callsign $newUser = $uid !== 0 ? false : true; if ($newUser) { // a new user, be happy :) if ($config->getValue('login.welcome.summary')) { $this->moduleOutput[] = strval($config->getValue('login.welcome.summary')); } else { $this->moduleOutput[] = 'Welcome and thanks for registering on this website.'; } // register the account on db if ($uid = $userOperations->registerAccount($moduleInstance, $externalLogin)) { // send welcome message if registering was successful \pm::sendWelcomeMessage($uid); } } else { // existing account with no external login // call logout as bandaid for erroneous login modules $user->logout(); $this->moduleOutput[] = 'This account does not have any external logins enabled. ' . 'You may try using ' . '<a href="./?module=local&action=form">local login</a>' . ' first.'; // login failed without any possibility to recover from user error return false; } // does a user try to log in using reserved id 0? if ($uid === 0) { // call logout as bandaid for erroneous login modules // these may log the user in, even though they never should $user->logout(); $this->moduleOutput[] = 'An internal error occurred: $uid === 0 on login.'; return false; } } $user = new \user($uid); // re-activate deleted accounts // stop processing disabled/banned or broken accounts // call logout as bandaid for erroneous login modules $status = $user->getStatus(); switch ($status) { case 'active': break; case 'deleted': $user->setStatus('active'); break; case 'login disabled': $this->moduleOutput[] = 'Your account is disabled: No login possible.'; $user->logout(); return false; break; // TODO: implement site wide ban list // TODO: implement site wide ban list case 'banned': $this->moduleOutput[] = 'You have been banned from this website.'; $user->logout(); return false; break; default: $this->moduleOutput[] = 'The impossible happened: Account status is' . htmlent($status) . '.'; $user->logout(); return false; } if ($uid > 0) { // update username first because online user list uses the name directly instead of an id //hmm, uid := $moduleInstance->getID() $userOperations->updateUserName($uid, $externalLogin ? $moduleInstance->getID() : 0, $moduleInstance->getName()); user::setCurrentUserID($uid); $moduleInstance->givePermissions(); $userOperations->addToVisitsLog($uid); $user->setLastLogin(); $user->update(); $userOperations->addToOnlineUserList($moduleInstance->getName(), $uid); invitation::deleteOldInvitations(); $this->moduleOutput[] = 'Login was successful!'; return true; } else { $user->logout(); } return false; }