public function getInitialEventsList() { $sql = 'SELECT e.*, o.id AS organizerId, o.title AS organizerTitle FROM events e LEFT JOIN organizers o ON e.organizer = o.id WHERE e.dateStart > now()'; $stmt = DatabaseFactory::getInstance()->prepare($sql); $stmt->execute(); return $stmt->fetchAll(); }
function sendEmail($recipient, $content, $subject = 'Notification', $includeStandardFooter = true) { $subject = 'lanlist.org - ' . $subject; if (empty($content)) { throw new Exception('Cannot send a blank email'); } $content = wordwrap($content); if ($includeStandardFooter) { $content .= "\n\n- lanlist.org"; } ErrorHandler::getInstance()->beLazy(); require_once 'Mail.php'; require_once 'Mail/smtp.php'; $host = 'ssl://smtp.gmail.com'; $username = '******'; $password = '******'; $smtp = new Mail_smtp(array('host' => $host, 'port' => 465, 'auth' => true, 'username' => $username, 'password' => $password)); $headers = array('From' => '"lanlist.org" <*****@*****.**>', 'To' => '<' . $recipient . '>', 'Subject' => $subject, 'Content-Type' => 'text/html'); $smtp->send('<' . $recipient . '>', $headers, $content); ErrorHandler::getInstance()->beGreedy(); Logger::messageDebug('Sending email to ' . $recipient . ', subject: ' . $subject); $sql = 'INSERT INTO email_log (subject, emailAddress, sent) VALUES (:subject, :emailAddress, now())'; $stmt = DatabaseFactory::getInstance()->prepare($sql); $stmt->bindValue(':emailAddress', $recipient); $stmt->bindValue(':subject', $subject); $stmt->execute(); }
public function changePassword($newPassword) { global $authBackend; $sql = 'UPDATE users SET password = :password WHERE id = :id'; $stmt = DatabaseFactory::getInstance()->prepare($sql); $stmt->bindValue(':id', $this->getElementValue('uid')); $stmt->bindValue(':password', $authBackend->hashPassword($newPassword)); $stmt->execute(); echo 'password changed for uid: ' . $this->getElementValue('uid'); }
public function getAll() { $sql = 'SELECT a.* FROM finance_accounts a'; $stmt = DatabaseFactory::getInstance()->prepare($sql); $stmt->execute(); $listAccounts = array(); foreach ($stmt->fetchAll() as $itemAccount) { $accounts = new ItemFinanceAccount($itemAccount); } return $listAccounts; }
public function __construct() { parent::__construct('formSendEmailToUser', 'Send email to user'); Session::requirePriv('SEND_EMAIL'); $uid = $_REQUEST['formSendEmailToUser-uid']; $uid = intval($uid); $this->user = User::getUserById($uid); $sql = 'SELECT o.* FROM users u LEFT JOIN organizers o ON u.organization = o.id WHERE u.id = :userId LIMIT 1'; $stmt = DatabaseFactory::getInstance()->prepare($sql); $stmt->bindValue(':userId', $this->user->getId()); $stmt->execute(); if ($stmt->numRows()) { $this->organizer = $stmt->fetchRow(); } else { $this->organizer = array('title' => '???', 'id' => '0'); } $this->addElement(Element::factory('hidden', 'uid', null, $uid)); $this->addElement(Element::factory('text', 'email', 'Send to', $this->user->getData('email'), 'User: <a href = "viewUser.php?id=' . $this->user->getId() . '">' . $this->user->getData('username') . '</a> Organizer: <a href = "viewOrganizer.php?id=' . $this->organizer['id'] . '">' . $this->organizer['title'] . '</a>')); $this->addElement(Element::factory('text', 'subject', 'Subject', 'Message from a human!')); $this->addElement(Element::factory('textarea', 'body', 'Body', 'Hey ' . $this->user->getUsername() . ', ' . "\n\n" . 'Your message here.' . "\n\n- lanlist.org ", 'No footer will be appended. From: mailer@lanlist.org')); $this->loadTemplate(); $this->addButtons(Form::BTN_SUBMIT); }
<?php require_once 'includes/widgets/header.php'; $groupId = Sanitizer::getInstance()->filterUint('id'); $sql = 'SELECT g.id, g.title FROM groups g WHERE g.id = :id'; $stmt = DatabaseFactory::getInstance()->prepare($sql); $stmt->bindValue(':id', $groupId); $stmt->execute(); $tpl->assign('itemGroup', $stmt->fetchRow()); $sql = 'SELECT u.id, "secondary" as source, u.username FROM group_memberships m LEFT JOIN users u ON m.user = u.id WHERE m.group = :id1 UNION SELECT u.id, "primary" as source, u.username FROM users u WHERE u.group = :id2'; $stmt = DatabaseFactory::getInstance()->prepare($sql); $stmt->bindValue(':id1', $groupId); $stmt->bindValue(':id2', $groupId); $stmt->execute(); $tpl->assign('listMembers', $stmt->fetchAll()); $sql = 'SELECT p.`key`, p.description FROM privileges_g gp LEFT JOIN permissions p ON gp.permission = p.id WHERE gp.group = :gid'; $stmt = DatabaseFactory::getInstance()->prepare($sql); $stmt->bindValue(':gid', $groupId); $stmt->execute(); $tpl->assign('listPrivileges', $stmt->fetchAll()); $tpl->display('viewGroup.tpl'); require_once 'includes/widgets/footer.php';