<?php model::load('login', 'login'); //Stop session token::delimda(); stop_session(); // Aller Page d'index //header ('location:./'); view::load('login', 'error');
function send_comment($commentID, $emailRecipients, $email_receive = false, $files = array()) { $comment = new comment(); $comment->set_id($commentID); $comment->select(); $token = new token(); if ($comment->get_value("commentType") == "comment" && $comment->get_value("commentLinkID")) { $c = new comment(); $c->set_id($comment->get_value("commentLinkID")); $c->select(); $is_a_reply_comment = true; if ($token->select_token_by_entity_and_action("comment", $c->get_id(), "add_comment_from_email")) { $hash = $token->get_value("tokenHash"); } } if (!$hash) { if ($token->select_token_by_entity_and_action("comment", $comment->get_id(), "add_comment_from_email")) { $hash = $token->get_value("tokenHash"); } else { $hash = $comment->make_token_add_comment_from_email(); } } $rtn = $comment->send_emails($emailRecipients, $email_receive, $hash, $is_a_reply_comment, $files); if (is_array($rtn)) { $email_sent = true; list($successful_recipients, $messageid) = $rtn; } // Append success to end of the comment if ($successful_recipients) { $append_comment_text = "Email sent to: " . $successful_recipients; $message_good .= $append_comment_text; //$comment->set_value("commentEmailMessageID",$messageid); that's the outbound message-id :-( $comment->set_value("commentEmailRecipients", $successful_recipients); } $comment->skip_modified_fields = true; $comment->updateSearchIndexLater = true; $comment->save(); return $email_sent; }
if (trim($title) == '') { throw new Exception('标题不能为空'); } if (trim($content) == '') { throw new Exception('内容不能为空'); } $token = new token($USER); $ok = $token->check($_POST['token']); if (!$ok) { throw new EXception('会话已过期,请重新发布'); } $token->delete(); $bbs = new bbs($USER); $ok = $bbs->newtopic($fid, $title, $content); if (!$ok) { throw new Exception('未知原因发帖失败,请重试或联系管理员'); } $tpl->assign('tid', $ok); $tpl->display('tpl:topicsuccess'); } else { throw new Exception(''); } } catch (Exception $err) { $tpl->assign('err', $err); if ($USER->islogin) { $token = new token($USER); $token->create(); $tpl->assign('token', $token); } $tpl->display('tpl:topicform'); }
public static function get_list($_FORM) { $filter = token::get_list_filter($_FORM); if (is_array($filter) && count($filter)) { $filter = " WHERE " . implode(" AND ", $filter); } $q = "SELECT * FROM token " . $filter; $db = new db_alloc(); $db->query($q); while ($row = $db->next_record()) { $rows[$row["tokenID"]] = $row; } return (array) $rows; }
<?php /* * Handles user login * */ if (isset($_GET['request_token'])) { $request_token = token::findbytoken($_GET['request_token']); echo $request_token->gettoken(); if (is_object($request_token) && $request_token->isrequest()) { if (!isset($_POST['login'])) { //echo form ?> <div id="login_form"> <form method="post"> <label for="user_name">User Name:</label> <input type="text" name="user_name" /><br/> <label for="password">Password:</label> <input type="password" name="password"/><br/> <input type="submit" name="login"/> </form> </div> <?php } else { //process form and redirect to callback url $user = user::findbyusername($_POST['user_name'], $_POST['password']); if (is_object($user)) { $request_token->setverifier(provider::generateverifier()); $request_token->setuser($user); header("Location: " . $request_token->getcallbackurl() . "?request_token=" . $request_token->gettoken() . "&verifier=" . $request_token->getverifier()); } else { echo "Invalid user name or password";
function add_comment_via_email($commands, $email_receive) { // If there's Key in the email, then add a comment with the contents of the email. $token = new token(); if ($commands["key"] && $token->set_hash($commands["key"])) { $db = new db_alloc(); $comment = $token->get_value("tokenEntity"); $commentID = $token->get_value("tokenEntityID"); list($entity, $method) = $token->execute(); if (is_object($entity) && $method == "add_comment_from_email") { $c = comment::add_comment_from_email($email_receive, $entity); if (is_object($c) && $c->get_id()) { $quiet = interestedParty::adjust_by_email_subject($email_receive, $entity); if ($commands["ip"]) { $rtn = interestedParty::add_remove_ips($commands["ip"], $entity->classname, $entity->get_id(), $entity->get_project_id()); } if (!$quiet) { comment::send_comment($c->get_id(), array("interested"), $email_receive); } } } // Bad or missing key, then error } else { if ($email_receive) { alloc_error("Bad or missing key. Unable to process email."); } } return array($status, $message); }
<h2>Looking for a way to find people to play some of your favourite games with? Then look no more! Gamerlocator is a simple app that will help you find gamers to play with via game genres.</h2> </div> </div> <div class="row"> <div class="col-sm-6 col-md-4 col-md-offset-4"> <div class="account-wall"> <h1 class="text-center login-title">Sign in to continue to Gamerlocator</h1> <form class="form-signin" action="" method="post"> <input type="text" class="form-control" name="username" id="username" autocomplete="off" placeholder="username" required autofocus> <input type="password" class="form-control" name="password" id="password" autocomplete="off" placeholder="Password" required> <input type="hidden" name="token" value="<?php echo token::generate(); ?> " > <button class="btn btn-lg btn-primary btn-block" type="submit"> Sign in</button> <label class="checkbox pull-left"> <input type="checkbox" name="remember" id="remember" > Remember me </label> </form> </div> <a href="register.php" class="text-center new-account">Create an account </a> </div> </div>
function add_notification($tokenActionID, $maxUsed, $name, $desc, $recipients, $datetime = false) { $current_user =& singleton("current_user"); $token = new token(); $token->set_value("tokenEntity", "task"); $token->set_value("tokenEntityID", $this->get_id()); $token->set_value("tokenActionID", $tokenActionID); $token->set_value("tokenActive", 1); $token->set_value("tokenMaxUsed", $maxUsed); $token->set_value("tokenCreatedBy", $current_user->get_id()); $token->set_value("tokenCreatedDate", date("Y-m-d H:i:s")); $hash = $token->generate_hash(); $token->set_value("tokenHash", $hash); $token->save(); if ($token->get_id()) { $reminder = new reminder(); $reminder->set_value("reminderType", "task"); $reminder->set_value("reminderLinkID", $this->get_id()); $reminder->set_value("reminderHash", $hash); $reminder->set_value("reminderSubject", $name); $reminder->set_value("reminderContent", $desc); if ($datetime) { $reminder->set_value("reminderTime", $datetime); } $reminder->save(); if ($reminder->get_id()) { foreach ($recipients as $row) { $reminderRecipient = new reminderRecipient(); $reminderRecipient->set_value("reminderID", $reminder->get_id()); $reminderRecipient->set_value($row["field"], $row["who"]); $reminderRecipient->save(); } } } }
function checkpass($password) { global $db; $reqpass = "******" . $_SESSION['userid'] . " and pass='******'"; $lasession = isset($_SESSION['sign']) && $password == $_SESSION['sign'] ? 1 : 0; if (isset($_SESSION['sign']) && $password !== $_SESSION['sign']) { token::delimda(); } $lepass = $db->QuerySingleValue0($reqpass) == 1 ? 1 : 0; if ($lepass == 1 && !isset($_SESSION['sign'])) { token::creatimda(); } $return = $lasession == 1 || $lepass == 1 ? 1 : 0; return $return; }
$c = new comment(); $c->set_id($_REQUEST["commentID"]); $c->select(); $entity = $c->get_value("commentMaster"); $entityID = $c->get_value("commentMasterID"); $mail = new email_receive($info); $mail->open_mailbox(config::get_config_item("allocEmailFolder") . "/" . $entity . $entityID); if ($_REQUEST["uid"]) { header('Content-Type: text/plain; charset=utf-8'); list($h, $b) = $mail->get_raw_email_by_msg_uid($_REQUEST["uid"]); $mail->close(); echo $h . $b; exit; } //$uids = $mail->get_all_email_msg_uids(); $t = new token(); $t->select_token_by_entity_and_action($c->get_value("commentType"), $c->get_value("commentLinkID"), "add_comment_from_email"); $hash = $t->get_value("tokenHash"); // First try a messageID search if ($c->get_value("commentEmailMessageID")) { $str = sprintf('TEXT "%s"', $c->get_value("commentEmailMessageID")); $uids = $mail->get_emails_UIDs_search($str); if (count($uids) == 1) { alloc_redirect($TPL["url_alloc_downloadEmail"] . "commentID=" . $_REQUEST["commentID"] . "&uid=" . $uids[0]); } else { if (count($uids) > 1) { $all_uids += $uids; } } } // Next try a hash lookup
function archive($mailbox = null) { $keys = $this->get_hashes(); $token = new token(); if ($keys && is_array($keys) && $token->set_hash($keys[0])) { if ($token->get_value("tokenEntity") == "comment") { $db = new db_alloc(); $row = $db->qr("SELECT commentMaster,commentMasterID \n FROM comment\n WHERE commentID = %d", $token->get_value("tokenEntityID")); $m = $row["commentMaster"]; $mID = $row["commentMasterID"]; $mailbox = "INBOX/" . $m . $mID; } else { $m = $token->get_value("tokenEntity"); $mID = $token->get_value("tokenEntityID"); $mailbox = "INBOX/" . $m . $mID; } } $mailbox or $mailbox = "INBOX"; // Some IMAP servers like dot-separated mail folders, some like slash-separated if ($mailbox) { $this->create_mailbox($mailbox); if ($this->msg_uid) { $this->move_mail($this->msg_uid, $mailbox); } else { if ($this->msg_text) { $this->append($mailbox, $this->msg_text); } } } }
private function getToken($open = array(), $close = false, $str = false, $ws = false, $split = false) { $t = ""; $sPos = $this->i; $t = new token(); if ($ws === false) { $ws = $this->whiteSpace; } if ($str === false) { $str = $this->stringChars; } if ($split === false) { $split = array(); } $t->start = $this->i; if ($close === false) { do { $c = $this->data[$this->i]; if (isset($str[$c])) { $schar = $c; //$t->a($c); $t->len++; $t->t .= $c; do { $escape = $this->data[$this->i] == "\\" && !$escape; $this->i++; //$t->a($this->data{$this->i}); $t->len++; $t->t .= $this->data[$this->i]; } while ($this->i < $this->len && ($this->data[$this->i] != $schar || $escape)); } else { if (in_array($c, $open)) { $t->endChar = $c; return $t; } else { if (isset($ws[$c])) { //do nothing? } else { if (isset($split[$c])) { $t->split(); } else { //$t->a($c); $t->len++; $t->t .= $c; } } } } } while (++$this->i <= $this->len); } else { $level = 0; do { $c = $this->data[$this->i]; if (isset($str[$c])) { $schar = $c; //$t->a($c); $t->len++; $t->t .= $c; do { $escape = $this->data[$this->i] == "\\" && !$escape; $this->i++; //$t->a($this->data{$this->i}); $t->len++; $t->t .= $this->data[$this->i]; } while ($this->i < $this->len && ($this->data[$this->i] != $schar || $escape)); } else { if (in_array($c, $open)) { $level++; if ($level > 1) { //$t->a($c); $t->len++; $t->t .= $c; } } else { if (in_array($c, $close)) { $level--; if ($level > 0) { //$t->a($c); $t->len++; $t->t .= $c; } } else { if (isset($ws[$c])) { //do nothing? } else { if (isset($split[$c])) { $t->split(); } else { //$t->a($c); $t->len++; $t->t .= $c; } } } } } } while (++$this->i <= $this->len && $level > 0); $t->endChar = $this->data[$this->i - 1]; return $t; } }
public function checktoken($provider) { $token = token::findbytoken($provider->token); if (is_null($token)) { return OAUTH_TOKEN_REJECTED; } else { if ($token->gettype() == 1 && $token->getverifier() != $provider->verifier) { return OAUTH_VERIFIER_INVALID; } else { if ($token->gettype() == 2) { $this->user = $token->getuser(); } $provider->token_secret = $token->gettokensecret(); return OAUTH_OK; } } }
/** * Check wheter client is authorized and returns Response object with autorization request if not * @return mixed Response object if client is not authorized, otherwise nothing */ private function verifyAuthentication() { $authenticated = false; $headers = getallheaders(); if (isset($headers['Authorization'])) { $token = str_replace('Token ', '', $headers['Authorization']); $authenticated = token::verify($token); } if ($authenticated === false) { $response = new Response(); $response->setStatus(401, 'Unauthorized')->addHeaders('WWW-Authenticate: Token'); return $response; } }
public static function session_autoclosed() { global $db; if (isset($_SESSION['ssid'])) { $ssid = $_SESSION['ssid']; $expired = $db->QuerySingleValue0("select expir from session where id='{$ssid}'"); if ($expired != NULL) { Cookie::close_session_open(); model::load('login', 'login'); //Stop session stop_session(); token::delimda(); $msg = "Vous êtes déconnecté automatiquement pour inactivité de 5 min {$expired} {$ssid} , redirection vers page login.... "; exit(msgbox($msg, 0, './', 5)); } } }
// save and return to list if ($_POST["reminder_save"] || $_POST["reminder_update"]) { $recipient_keys = $_POST["reminder_recipient"]; // make 24 hour with 12am = 0 -> 11am = 11 -> 12pm = 12 -> 11pm = 23 if ($_POST["reminder_hour"] == 12) { $_POST["reminder_hour"] = 0; } if ($_POST["reminder_meridian"] == "pm") { $_POST["reminder_hour"] += 12; } $reminder = new reminder(); if (isset($_POST["reminder_update"])) { $reminder->set_id($_POST["reminder_id"]); $reminder->select(); if ($reminder->get_value("reminderHash")) { $token = new token(); $token->set_hash($reminder->get_value("reminderHash"), false); if ($token->get_value("tokenActionID") == 3) { $reminder->set_value("reminderTime", ""); $no = true; } } } $reminder->set_value('reminderType', $parentType); $reminder->set_value('reminderLinkID', $parentID); $reminder->set_value('reminderModifiedUser', $current_user->get_id()); $reminder->set_modified_time(); $no or $reminder->set_value('reminderTime', $_POST["reminder_date"] . " " . $_POST["reminder_hour"] . ":" . $_POST["reminder_minute"] . ":00"); $reminder->set_value('reminderHash', $_POST["reminderHash"]); if (!$_POST["reminder_recuring_value"]) { $reminder->set_value('reminderRecuringInterval', 'No');
<?php if (Input::exists()) { if (token::check(Input::get('token'))) { $val = new Validation(); $validation = $val->check($_POST, array('message' => array('required' => true))); if ($validation->passed()) { foreach ($db->get('users', array('1', '=', '1'))->results() as $userAcc) { try { Notifaction::createMessage(Input::get('message'), $userAcc->id); Session::flash('complete', 'You sent a mass message!'); Redirect::to('?page=notification'); } catch (Exception $e) { } } } } } ?> <!DOCTYPE html> <html lang="en"> <head> <?php include 'inc/templates/head.php'; ?> </head> <body> <div class="col-md-3"><?php include 'inc/templates/nav.php'; ?> </div>
function mail_reminder() { // check for a reminder.reminderHash that links off to a token.tokenHash // this lets us trigger reminders on complex actions, for example create // a reminder that sends when a task status changes from pending to open // Note this->reminderTime is going to always be null for the token that // link to task->moved_from_pending_to_open(). // Whereas the task->reopen_pending_task() will have a reminderTime set. $ok = true; if ($this->get_value("reminderHash")) { $token = new token(); if ($token->set_hash($this->get_value("reminderHash"))) { list($entity, $method) = $token->execute(); if (is_object($entity) && $entity->get_id()) { if (!$entity->{$method}()) { $token->decrement_tokenUsed(); // next time, gadget $ok = false; } } } } if ($ok) { $recipients = $this->get_all_recipients(); # Reminders can be clients, tasks, projects or "general" - comment threads don't exist for general if ($this->get_value('reminderType') != 'general') { # Nowhere to put the subject? $commentID = comment::add_comment($this->get_value('reminderType'), $this->get_value('reminderLinkID'), $this->get_value('reminderContent'), $this->get_value('reminderType'), $this->get_value('reminderLinkID')); # Repackage the recipients to become IPs of the new comment $ips = array(); foreach ((array) $recipients as $id => $person) { $ip = array(); $ip['name'] = $person['name']; $ip['addIP'] = true; $ip['addContact'] = false; $ip['internal'] = true; $ips[$person['emailAddress']] = $ip; } comment::add_interested_parties($commentID, false, $ips); # email_receive false or true? false for now... maybe true is better? comment::send_comment($commentID, array("interested")); } else { foreach ((array) $recipients as $person) { if ($person['emailAddress']) { $email = sprintf("%s %s <%s>", $person['firstName'], $person['surname'], $person['emailAddress']); $subject = $this->get_value('reminderSubject'); $content = $this->get_value('reminderContent'); $e = new email_send($email, $subject, $content, "reminder"); $e->send(); } } } // Update reminder (reminderTime can be blank for task->moved_from_pending_to_open) if ($this->get_value('reminderRecuringInterval') == "No") { $this->deactivate(); } else { if ($this->get_value('reminderRecuringValue') != 0) { $interval = $this->get_value('reminderRecuringValue'); $intervalUnit = $this->get_value('reminderRecuringInterval'); $newtime = $this->get_next_reminder_time(strtotime($this->get_value('reminderTime')), $interval, $intervalUnit); $this->set_value('reminderTime', date("Y-m-d H:i:s", $newtime)); $this->set_value('reminderAdvNoticeSent', 0); $this->save(); } } } }