/** * Constructor. */ function RegistrationForm($site) { parent::Form('user/register.tpl'); $this->implicitAuth = Config::getVar('security', 'implicit_auth'); // Validation checks for this form $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByUsername'), array(), true)); $this->addCheck(new FormValidator($this, 'username', 'required', 'user.profile.form.usernameRequired')); $this->addCheck(new FormValidator($this, 'password', 'required', 'user.profile.form.passwordRequired')); $this->addCheck(new FormValidatorAlphaNum($this, 'username', 'required', 'user.register.form.usernameAlphaNumeric')); $this->addCheck(new FormValidatorLength($this, 'password', 'required', 'user.register.form.passwordLengthTooShort', '>=', $site->getMinPasswordLength())); $this->addCheck(new FormValidatorCustom($this, 'password', 'required', 'user.register.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'password2\');'), array(&$this))); $this->addCheck(new FormValidator($this, 'firstName', 'required', 'user.profile.form.firstNameRequired')); $this->addCheck(new FormValidator($this, 'lastName', 'required', 'user.profile.form.lastNameRequired')); $this->addCheck(new FormValidator($this, 'country', 'required', 'user.profile.form.countryRequired')); // Email checks $this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'user.profile.form.emailRequired')); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByEmail'), array(), true)); $this->captchaEnabled = Config::getVar('captcha', 'captcha_on_register') && Config::getVar('captcha', 'recaptcha'); if ($this->captchaEnabled) { $this->addCheck(new FormValidatorReCaptcha($this, 'recaptcha_challenge_field', 'recaptcha_response_field', Request::getRemoteAddr(), 'common.captchaField.badCaptcha')); } $authDao = DAORegistry::getDAO('AuthSourceDAO'); $this->defaultAuth = $authDao->getDefaultPlugin(); if (isset($this->defaultAuth)) { $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', create_function('$username,$form,$auth', 'return (!$auth->userExists($username) || $auth->authenticate($username, $form->getData(\'password\')));'), array(&$this, $this->defaultAuth))); } $this->addCheck(new FormValidatorPost($this)); }
/** * Constructor. */ function __construct($site) { parent::__construct('frontend/pages/userRegister.tpl'); // Validation checks for this form $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByUsername'), array(), true)); $this->addCheck(new FormValidator($this, 'username', 'required', 'user.profile.form.usernameRequired')); $this->addCheck(new FormValidator($this, 'password', 'required', 'user.profile.form.passwordRequired')); $this->addCheck(new FormValidatorUsername($this, 'username', 'required', 'user.register.form.usernameAlphaNumeric')); $this->addCheck(new FormValidatorLength($this, 'password', 'required', 'user.register.form.passwordLengthRestriction', '>=', $site->getMinPasswordLength())); $this->addCheck(new FormValidatorCustom($this, 'password', 'required', 'user.register.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'password2\');'), array(&$this))); $this->addCheck(new FormValidator($this, 'firstName', 'required', 'user.profile.form.firstNameRequired')); $this->addCheck(new FormValidator($this, 'lastName', 'required', 'user.profile.form.lastNameRequired')); $this->addCheck(new FormValidator($this, 'country', 'required', 'user.profile.form.countryRequired')); // Email checks $this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'user.profile.form.emailRequired')); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByEmail'), array(), true)); $this->captchaEnabled = Config::getVar('captcha', 'captcha_on_register') && Config::getVar('captcha', 'recaptcha'); if ($this->captchaEnabled) { $this->addCheck(new FormValidatorReCaptcha($this, Request::getRemoteAddr(), 'common.captcha.error.invalid-input-response')); } $authDao = DAORegistry::getDAO('AuthSourceDAO'); $this->defaultAuth = $authDao->getDefaultPlugin(); if (isset($this->defaultAuth)) { $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', create_function('$username,$form,$auth', 'return (!$auth->userExists($username) || $auth->authenticate($username, $form->getData(\'password\')));'), array(&$this, $this->defaultAuth))); } $this->addCheck(new FormValidatorPost($this)); $this->addCheck(new FormValidatorCSRF($this)); }
/** * Constructor. * @param $archiveId omit for a new archive */ function ArchiveForm($archiveId = null, $allowManagement = false) { parent::Form('admin/archiveForm.tpl'); $this->archiveId = isset($archiveId) ? (int) $archiveId : null; $this->allowManagement = $allowManagement; // Validation checks for this form $this->addCheck(new FormValidator($this, 'title', 'required', 'admin.archives.form.titleRequired')); $this->addCheck(new FormValidator($this, 'url', 'required', 'admin.archives.form.urlRequired')); $this->addCheck(new FormValidatorPost($this)); $this->captchaEnabled = Config::getVar('captcha', 'captcha_on_submit') && Config::getVar('captcha', 'recaptcha'); if ($this->captchaEnabled && !Validation::isSiteAdmin()) { $this->addCheck(new FormValidatorReCaptcha($this, 'recaptcha_challenge_field', 'recaptcha_response_field', Request::getRemoteAddr(), 'common.captchaField.badCaptcha')); } $this->harvesterPluginName = Request::getUserVar('harvesterPluginName'); if ($archiveId) { $archiveDao = DAORegistry::getDAO('ArchiveDAO'); $this->archive =& $archiveDao->getArchive($this->archiveId, false); if (empty($this->harvesterPluginName) && $this->archive) { $this->harvesterPluginName = $this->archive->getHarvesterPluginName(); } } if (empty($this->harvesterPluginName)) { $site =& Request::getSite(); $this->harvesterPluginName = $site->getSetting('defaultHarvesterPlugin'); } $this->harvesters =& PluginRegistry::loadCategory('harvesters'); HookRegistry::call('ArchiveForm::ArchiveForm', array(&$this, $this->harvesterPluginName)); }
/** * Constructor. */ function CommentForm($commentId, $articleId, $galleyId, $parentId = null) { parent::Form('comment/comment.tpl'); $this->articleId = $articleId; $commentDao =& DAORegistry::getDAO('CommentDAO'); $this->comment =& $commentDao->getById($commentId, $articleId); import('lib.pkp.classes.captcha.CaptchaManager'); $captchaManager = new CaptchaManager(); $this->captchaEnabled = $captchaManager->isEnabled() && Config::getVar('captcha', 'captcha_on_comments') ? true : false; if ($this->captchaEnabled) { $this->reCaptchaEnabled = Config::getVar('captcha', 'recaptcha') ? true : false; } if (isset($this->comment)) { $this->commentId = $commentId; } $this->parentId = $parentId; $this->galleyId = $galleyId; $this->addCheck(new FormValidator($this, 'title', 'required', 'comments.titleRequired')); if ($this->captchaEnabled) { if ($this->reCaptchaEnabled) { $this->addCheck(new FormValidatorReCaptcha($this, 'recaptcha_challenge_field', 'recaptcha_response_field', Request::getRemoteAddr(), 'common.captchaField.badCaptcha')); } else { $this->addCheck(new FormValidatorCaptcha($this, 'captcha', 'captchaId', 'common.captchaField.badCaptcha')); } } $this->addCheck(new FormValidatorPost($this)); }
/** * Prevent the Harvester from responding to certain IP addresses. */ function _loadHandlerCallback($hookName, $args) { $ips = array(); @($ips = array_map('rtrim', file(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ips.txt'))); if (is_array($ips) && in_array(Request::getRemoteAddr(), $ips)) { exit; } return false; }
/** * Constructor. */ function NotificationMailingListForm() { parent::Form('notification/maillist.tpl'); $this->captchaEnabled = Config::getVar('captcha', 'captcha_on_mailinglist') && Config::getVar('captcha', 'recaptcha'); // Validation checks for this form if ($this->captchaEnabled) { $this->addCheck(new FormValidatorReCaptcha($this, 'recaptcha_challenge_field', 'recaptcha_response_field', Request::getRemoteAddr(), 'common.captchaField.badCaptcha')); } $this->addCheck(new FormValidatorPost($this)); $this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'notification.mailList.emailInvalid')); }
/** * Hook callback function for IssueAction::subscriptionRequired */ function validSubscriptionIp($hookName, $args) { $result =& $args[2]; $ipDao =& DAORegistry::getDAO('IpSubscriptionsDAO'); if ($ipDao->isCRKNSubscriber(Request::getRemoteAddr())) { $result = false; // CRKN IP and past moving wall - subscription not required return true; } return false; }
/** * Constructor. */ function NotificationMailingListForm() { parent::Form('notification/maillist.tpl'); $this->captchaEnabled = Config::getVar('captcha', 'captcha_on_mailinglist') && Config::getVar('captcha', 'recaptcha'); // Validation checks for this form if ($this->captchaEnabled) { $this->addCheck(new FormValidatorReCaptcha($this, 'recaptcha_challenge_field', 'recaptcha_response_field', Request::getRemoteAddr(), 'common.captchaField.badCaptcha')); } $this->addCheck(new FormValidatorPost($this)); $this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'notification.mailList.emailInvalid')); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailsDoNotMatch', create_function('$email,$form', 'return $email == $form->getData(\'confirmEmail\');'), array($this))); }
/** * Constructor. * Initialize session configuration and set PHP session handlers. * Attempts to rejoin a user's session if it exists, or create a new session otherwise. */ function SessionManager(&$sessionDao) { $this->sessionDao =& $sessionDao; // Configure PHP session parameters ini_set('session.use_trans_sid', 0); ini_set('session.save_handler', 'user'); ini_set('session.serialize_handler', 'php'); ini_set('session.use_cookies', 1); ini_set('session.name', Config::getVar('general', 'session_cookie_name')); // Cookie name ini_set('session.cookie_lifetime', 0); ini_set('session.cookie_path', Request::getBasePath() . '/'); ini_set('session.gc_probability', 1); ini_set('session.gc_maxlifetime', 60 * 60); ini_set('session.auto_start', 1); ini_set('session.cache_limiter', 'none'); session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc')); // Initialize the session session_start(); $sessionId = session_id(); $ip = Request::getRemoteAddr(); $userAgent = Request::getUserAgent(); $now = time(); if (!isset($this->userSession) || Config::getVar('security', 'session_check_ip') && $this->userSession->getIpAddress() != $ip || $this->userSession->getUserAgent() != $userAgent) { if (isset($this->userSession)) { // Destroy old session session_destroy(); } // Create new session $this->userSession =& new Session(); $this->userSession->setId($sessionId); $this->userSession->setIpAddress($ip); $this->userSession->setUserAgent($userAgent); $this->userSession->setSecondsCreated($now); $this->userSession->setSecondsLastUsed($now); $this->userSession->setSessionData(''); $this->sessionDao->insertSession($this->userSession); } else { if ($this->userSession->getRemember()) { // Update session timestamp for remembered sessions so it doesn't expire in the middle of a browser session if (Config::getVar('general', 'session_lifetime') > 0) { $this->updateSessionLifetime(time() + Config::getVar('general', 'session_lifetime') * 86400); } else { $this->userSession->setRemember(0); $this->updateSessionLifetime(0); } } // Update existing session's timestamp $this->userSession->setSecondsLastUsed($now); $this->sessionDao->updateSession($this->userSession); } }
/** * Constructor. */ function RegistrationForm() { parent::Form('user/register.tpl'); $this->implicitAuth = Config::getVar('security', 'implicit_auth'); if ($this->implicitAuth) { // If implicit auth - it is always an existing user $this->existingUser = 1; } else { $this->existingUser = Request::getUserVar('existingUser') ? 1 : 0; import('lib.pkp.classes.captcha.CaptchaManager'); $captchaManager = new CaptchaManager(); $this->captchaEnabled = $captchaManager->isEnabled() && Config::getVar('captcha', 'captcha_on_register') ? true : false; if ($this->captchaEnabled) { $this->reCaptchaEnabled = Config::getVar('captcha', 'recaptcha') ? true : false; } // Validation checks for this form $this->addCheck(new FormValidator($this, 'username', 'required', 'user.profile.form.usernameRequired')); $this->addCheck(new FormValidator($this, 'password', 'required', 'user.profile.form.passwordRequired')); if ($this->existingUser) { // Existing user -- check login $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.login.loginError', create_function('$username,$form', 'return Validation::checkCredentials($form->getData(\'username\'), $form->getData(\'password\'));'), array(&$this))); } else { // New user -- check required profile fields $site =& Request::getSite(); $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByUsername'), array(), true)); $this->addCheck(new FormValidatorAlphaNum($this, 'username', 'required', 'user.register.form.usernameAlphaNumeric')); $this->addCheck(new FormValidatorLength($this, 'password', 'required', 'user.register.form.passwordLengthTooShort', '>=', $site->getMinPasswordLength())); $this->addCheck(new FormValidatorCustom($this, 'password', 'required', 'user.register.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'password2\');'), array(&$this))); $this->addCheck(new FormValidator($this, 'firstName', 'required', 'user.profile.form.firstNameRequired')); $this->addCheck(new FormValidator($this, 'lastName', 'required', 'user.profile.form.lastNameRequired')); $this->addCheck(new FormValidatorUrl($this, 'userUrl', 'optional', 'user.profile.form.urlInvalid')); $this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'user.profile.form.emailRequired')); $this->addCheck(new FormValidatorORCID($this, 'orcid', 'optional', 'user.profile.form.orcidInvalid')); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailsDoNotMatch', create_function('$email,$form', 'return $email == $form->getData(\'confirmEmail\');'), array(&$this))); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByEmail'), array(), true)); if ($this->captchaEnabled) { if ($this->reCaptchaEnabled) { $this->addCheck(new FormValidatorReCaptcha($this, 'recaptcha_challenge_field', 'recaptcha_response_field', Request::getRemoteAddr(), 'common.captchaField.badCaptcha')); } else { $this->addCheck(new FormValidatorCaptcha($this, 'captcha', 'captchaId', 'common.captchaField.badCaptcha')); } } $authDao =& DAORegistry::getDAO('AuthSourceDAO'); $this->defaultAuth =& $authDao->getDefaultPlugin(); if (isset($this->defaultAuth)) { $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', create_function('$username,$form,$auth', 'return (!$auth->userExists($username) || $auth->authenticate($username, $form->getData(\'password\')));'), array(&$this, $this->defaultAuth))); } } } $this->addCheck(new FormValidatorPost($this)); }
/** * Constructor. */ function CommentForm($commentId, $articleId, $galleyId, $parentId = null) { parent::Form('comment/comment.tpl'); $this->articleId = $articleId; $commentDao = DAORegistry::getDAO('CommentDAO'); $this->comment = $commentDao->getById($commentId, $articleId); $this->captchaEnabled = Config::getVar('captcha', 'captcha_on_comments') && Config::getVar('captcha', 'recaptcha'); if (isset($this->comment)) { $this->commentId = $commentId; } $this->parentId = $parentId; $this->galleyId = $galleyId; $this->addCheck(new FormValidator($this, 'title', 'required', 'comments.titleRequired')); if ($this->captchaEnabled) { $this->addCheck(new FormValidatorReCaptcha($this, 'recaptcha_challenge_field', 'recaptcha_response_field', Request::getRemoteAddr(), 'common.captchaField.badCaptcha')); } $this->addCheck(new FormValidatorPost($this)); }
/** * Get the HTML contents for this block. * @param $templateMgr object * @return $string */ function getContents(&$templateMgr) { $journal =& Request::getJournal(); $journalId = $journal ? $journal->getJournalId() : null; if (!$journal) { return ''; } $user =& Request::getUser(); $userId = $user ? $user->getUserId() : null; $domain = Request::getRemoteDomain(); $IP = Request::getRemoteAddr(); // This replicates the order of SubscriptionDAO::isValidSubscription // Checks for valid Subscription and assigns vars accordingly for display $subscriptionDao =& DAORegistry::getDAO('SubscriptionDAO'); $subscriptionId = false; $userHasSubscription = false; if ($userId != null) { $subscriptionId = $subscriptionDao->isValidSubscriptionByUser($userId, $journalId); $userHasSubscription = true; } if (!$userHasSubscription && $domain != null) { $subscriptionId = $subscriptionDao->isValidSubscriptionByDomain($domain, $journalId); } if (!$userHasSubscription && $IP != null) { $subscriptionId = $subscriptionDao->isValidSubscriptionByIP($IP, $journalId); } if ($subscriptionId !== false) { $subscription =& $subscriptionDao->getSubscription($subscriptionId); $templateMgr->assign('userHasSubscription', $userHasSubscription); if ($userHasSubscription) { import('payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $subscriptionEnabled = $paymentManager->acceptSubscriptionPayments(); $templateMgr->assign('subscriptionEnabled', $subscriptionEnabled); } $templateMgr->assign('subscriptionMembership', $subscription->getMembership()); $templateMgr->assign('subscriptionDateEnd', $subscription->getDateEnd()); $templateMgr->assign('subscriptionTypeName', $subscription->getSubscriptionTypeName()); $templateMgr->assign('userIP', $IP); return parent::getContents($templateMgr); } return ''; }
/** * Add a new event log entry with the specified parameters * @param $request object * @param $article object * @param $eventType int * @param $messageKey string * @param $params array optional * @return object ArticleLogEntry iff the event was logged */ function logEventHeadless(&$journal, $userId, &$article, $eventType, $messageKey, $params = array()) { // Create a new entry object $articleEventLogDao =& DAORegistry::getDAO('ArticleEventLogDAO'); $entry = $articleEventLogDao->newDataObject(); // Set implicit parts of the log entry $entry->setDateLogged(Core::getCurrentDate()); $entry->setIPAddress(Request::getRemoteAddr()); $entry->setUserId($userId); $entry->setAssocType(ASSOC_TYPE_ARTICLE); $entry->setAssocId($article->getId()); // Set explicit parts of the log entry $entry->setEventType($eventType); $entry->setMessage($messageKey); $entry->setParams($params); $entry->setIsTranslated(0); $entry->setParams($params); // Insert the resulting object $articleEventLogDao->insertObject($entry); return $entry; }
/** * Constructor. */ function PKPRegistrationForm($site, $existingUser = false) { parent::PKPUserForm('user/register.tpl'); $this->implicitAuth = Config::getVar('security', 'implicit_auth'); if ($this->implicitAuth) { // If implicit auth - it is always an existing user $this->existingUser = true; } else { $this->existingUser = $existingUser; $this->captchaEnabled = Config::getVar('captcha', 'captcha_on_register') && Config::getVar('captcha', 'recaptcha'); // Validation checks for this form $this->addCheck(new FormValidator($this, 'username', 'required', 'user.profile.form.usernameRequired')); $this->addCheck(new FormValidator($this, 'password', 'required', 'user.profile.form.passwordRequired')); if ($this->existingUser) { // Existing user -- check login $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.login.loginError', create_function('$username,$form', 'return Validation::checkCredentials($form->getData(\'username\'), $form->getData(\'password\'));'), array(&$this))); } else { // New user -- check required profile fields $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByUsername'), array(), true)); $this->addCheck(new FormValidatorAlphaNum($this, 'username', 'required', 'user.register.form.usernameAlphaNumeric')); $this->addCheck(new FormValidatorLength($this, 'password', 'required', 'user.register.form.passwordLengthTooShort', '>=', $site->getMinPasswordLength())); $this->addCheck(new FormValidatorCustom($this, 'password', 'required', 'user.register.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'password2\');'), array(&$this))); // Add base user form checks (first name, last name, ...) $this->_addBaseUserFieldChecks(); // Email checks $this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'user.profile.form.emailRequired')); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailsDoNotMatch', create_function('$email,$form', 'return $email == $form->getData(\'confirmEmail\');'), array(&$this))); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByEmail'), array(), true)); if ($this->captchaEnabled) { $this->addCheck(new FormValidatorReCaptcha($this, 'recaptcha_challenge_field', 'recaptcha_response_field', Request::getRemoteAddr(), 'common.captchaField.badCaptcha')); } $authDao = DAORegistry::getDAO('AuthSourceDAO'); $this->defaultAuth =& $authDao->getDefaultPlugin(); if (isset($this->defaultAuth)) { $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', create_function('$username,$form,$auth', 'return (!$auth->userExists($username) || $auth->authenticate($username, $form->getData(\'password\')));'), array(&$this, $this->defaultAuth))); } } } }
/** * Get the HTML contents for this block. * @param $templateMgr object * @return $string */ function getContents(&$templateMgr) { $journal =& Request::getJournal(); $journalId = $journal ? $journal->getId() : null; if (!$journal) { return ''; } if ($journal->getSetting('publishingMode') != PUBLISHING_MODE_SUBSCRIPTION) { return ''; } $user =& Request::getUser(); $userId = $user ? $user->getId() : null; $templateMgr->assign('userLoggedIn', isset($userId) ? true : false); if (isset($userId)) { $subscriptionDao =& DAORegistry::getDAO('IndividualSubscriptionDAO'); $individualSubscription =& $subscriptionDao->getSubscriptionByUserForJournal($userId, $journalId); $templateMgr->assign_by_ref('individualSubscription', $individualSubscription); } // If no individual subscription or if not valid, check for institutional subscription if (!isset($individualSubscription) || !$individualSubscription->isValid()) { $IP = Request::getRemoteAddr(); $domain = Request::getRemoteDomain(); $subscriptionDao =& DAORegistry::getDAO('InstitutionalSubscriptionDAO'); $subscriptionId = $subscriptionDao->isValidInstitutionalSubscription($domain, $IP, $journalId); if ($subscriptionId) { $institutionalSubscription =& $subscriptionDao->getSubscription($subscriptionId); $templateMgr->assign_by_ref('institutionalSubscription', $institutionalSubscription); $templateMgr->assign('userIP', $IP); } } if (isset($individualSubscription) || isset($institutionalSubscription)) { import('classes.payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); $acceptSubscriptionPayments = $paymentManager->acceptSubscriptionPayments(); $templateMgr->assign('acceptSubscriptionPayments', $acceptSubscriptionPayments); } return parent::getContents($templateMgr); }
/** * Constructor * @param $typeId int Registration type to use * @param $registration object optional registration option if one already exists * @param $request PKPRequest */ function UserRegistrationForm($typeId, $registration, &$request) { $schedConf =& $request->getSchedConf(); $this->typeId = (int) $typeId; $this->_registration = $registration; $this->request =& $request; parent::Form('registration/userRegistrationForm.tpl'); $this->addCheck(new FormValidatorCustom($this, 'registrationTypeId', 'required', 'manager.registration.form.typeIdValid', create_function('$registrationTypeId, $schedConfId, $typeId', '$registrationTypeDao = DAORegistry::getDAO(\'RegistrationTypeDAO\'); return $registrationTypeDao->openRegistrationTypeExistsByTypeId($typeId, $schedConfId);'), array($schedConf->getId(), $typeId))); $this->captchaEnabled = Config::getVar('captcha', 'captcha_on_register') && Config::getVar('captcha', 'recaptcha'); $user =& $request->getUser(); if (!$user) { $site =& $request->getSite(); $this->addCheck(new FormValidator($this, 'username', 'required', 'user.profile.form.usernameRequired')); $this->addCheck(new FormValidator($this, 'password', 'required', 'user.profile.form.passwordRequired')); $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.account.form.usernameExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByUsername'), array(), true)); $this->addCheck(new FormValidatorAlphaNum($this, 'username', 'required', 'user.account.form.usernameAlphaNumeric')); $this->addCheck(new FormValidatorLength($this, 'password', 'required', 'user.account.form.passwordLengthTooShort', '>=', $site->getMinPasswordLength())); $this->addCheck(new FormValidatorCustom($this, 'password', 'required', 'user.account.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'password2\');'), array(&$this))); $this->addCheck(new FormValidator($this, 'firstName', 'required', 'user.profile.form.firstNameRequired')); $this->addCheck(new FormValidator($this, 'lastName', 'required', 'user.profile.form.lastNameRequired')); $this->addCheck(new FormValidator($this, 'country', 'required', 'user.profile.form.countryRequired')); $this->addCheck(new FormValidator($this, 'mailingAddress', 'required', 'user.profile.form.mailingAddressRequired')); $this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'user.profile.form.emailRequired')); $this->addCheck(new FormValidator($this, 'affiliation', 'required', 'user.profile.form.affiliationRequired')); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.account.form.emailExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByEmail'), array(), true)); if ($this->captchaEnabled) { $this->addCheck(new FormValidatorReCaptcha($this, 'recaptcha_challenge_field', 'recaptcha_response_field', Request::getRemoteAddr(), 'common.captchaField.badCaptcha')); } $authDao = DAORegistry::getDAO('AuthSourceDAO'); $this->defaultAuth =& $authDao->getDefaultPlugin(); if (isset($this->defaultAuth)) { $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.account.form.usernameExists', create_function('$username,$form,$auth', 'return (!$auth->userExists($username) || $auth->authenticate($username, $form->getData(\'password\')));'), array(&$this, $this->defaultAuth))); } } $this->addCheck(new FormValidatorPost($this)); }
/** * Constructor. */ function CreateAccountForm() { parent::Form('user/createAccount.tpl'); $this->existingUser = Request::getUserVar('existingUser') ? 1 : 0; $this->captchaEnabled = Config::getVar('captcha', 'captcha_on_register') && Config::getVar('captcha', 'recaptcha'); // Validation checks for this form $this->addCheck(new FormValidator($this, 'username', 'required', 'user.profile.form.usernameRequired')); $this->addCheck(new FormValidator($this, 'password', 'required', 'user.profile.form.passwordRequired')); if ($this->existingUser) { // Existing user -- check login $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.login.loginError', create_function('$username,$form', 'return Validation::checkCredentials($form->getData(\'username\'), $form->getData(\'password\'));'), array(&$this))); } else { // New user -- check required profile fields $site =& Request::getSite(); $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.account.form.usernameExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByUsername'), array(), true)); $this->addCheck(new FormValidatorAlphaNum($this, 'username', 'required', 'user.account.form.usernameAlphaNumeric')); $this->addCheck(new FormValidatorLength($this, 'password', 'required', 'user.account.form.passwordLengthTooShort', '>=', $site->getMinPasswordLength())); $this->addCheck(new FormValidatorCustom($this, 'password', 'required', 'user.account.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'password2\');'), array(&$this))); $this->addCheck(new FormValidator($this, 'firstName', 'required', 'user.profile.form.firstNameRequired')); $this->addCheck(new FormValidator($this, 'lastName', 'required', 'user.profile.form.lastNameRequired')); $this->addCheck(new FormValidatorUrl($this, 'userUrl', 'optional', 'user.profile.form.urlInvalid')); $this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'user.profile.form.emailRequired')); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailsDoNotMatch', create_function('$email,$form', 'return $email == $form->getData(\'confirmEmail\');'), array(&$this))); $this->addCheck(new FormValidator($this, 'affiliation', 'required', 'user.profile.form.affiliationRequired')); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.account.form.emailExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByEmail'), array(), true)); if ($this->captchaEnabled) { $this->addCheck(new FormValidatorReCaptcha($this, 'recaptcha_challenge_field', 'recaptcha_response_field', Request::getRemoteAddr(), 'common.captchaField.badCaptcha')); } $authDao = DAORegistry::getDAO('AuthSourceDAO'); $this->defaultAuth =& $authDao->getDefaultPlugin(); if (isset($this->defaultAuth)) { $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.account.form.usernameExists', create_function('$username,$form,$auth', 'return (!$auth->userExists($username) || $auth->authenticate($username, $form->getData(\'password\')));'), array(&$this, $this->defaultAuth))); } } $this->addCheck(new FormValidatorPost($this)); }
/** * Insert a new log entry. * @param $entry ArticleEmailLogEntry */ function insertLogEntry(&$entry) { if ($entry->getDateSent() == null) { $entry->setDateSent(Core::getCurrentDate()); } if ($entry->getIPAddress() == null) { $entry->setIPAddress(Request::getRemoteAddr()); } $this->update(sprintf('INSERT INTO article_email_log (article_id, sender_id, date_sent, ip_address, event_type, assoc_type, assoc_id, from_address, recipients, cc_recipients, bcc_recipients, subject, body) VALUES (?, ?, %s, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $this->datetimeToDB($entry->getDateSent())), array($entry->getArticleId(), $entry->getSenderId(), $entry->getIPAddress(), $entry->getEventType(), $entry->getAssocType(), $entry->getAssocId(), $entry->getFrom(), $entry->getRecipients(), $entry->getCcs(), $entry->getBccs(), $entry->getSubject(), $entry->getBody())); $entry->setLogId($this->getInsertLogId()); return $entry->getLogId(); }
/** * Constructor. */ function Comment() { parent::DataObject(); $this->setPosterIP(Request::getRemoteAddr()); }
/** * Get the remote domain of the current request * @return string */ function getRemoteDomain() { static $remoteDomain; if (!isset($remoteDomain)) { $remoteDomain = null; $remoteDomain = @getHostByAddr(Request::getRemoteAddr()); HookRegistry::call('Request::getRemoteDomain', array(&$remoteDomain)); } return $remoteDomain; }
/** * Checks if remote client domain or ip is allowed * @return bool */ function subscribedDomain(&$journal, $issueId = null, $articleId = null) { $subscriptionDao =& DAORegistry::getDAO('SubscriptionDAO'); $result = false; if (isset($journal)) { $result = $subscriptionDao->isValidSubscription(Request::getRemoteDomain(), Request::getRemoteAddr(), null, $journal->getJournalId()); // If no valid subscription, check if there is an expired subscription // that was valid during publication date of requested content if (!$result && $journal->getSetting('subscriptionExpiryPartial')) { if (isset($articleId)) { $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($articleId); if (isset($publishedArticle)) { import('subscription.SubscriptionDAO'); $result = $subscriptionDao->isValidSubscription(Request::getRemoteDomain(), Request::getRemoteAddr(), null, $journal->getJournalId(), SUBSCRIPTION_DATE_END, $publishedArticle->getDatePublished()); } } else { if (isset($issueId)) { $issueDao =& DAORegistry::getDAO('IssueDAO'); $issue =& $issueDao->getIssueById($issueId); if (isset($issue) && $issue->getPublished()) { import('subscription.SubscriptionDAO'); $result = $subscriptionDao->isValidSubscription(Request::getRemoteDomain(), Request::getRemoteAddr(), null, $journal->getJournalId(), SUBSCRIPTION_DATE_END, $issue->getDatePublished()); } } } } } HookRegistry::call('IssueAction::subscribedDomain', array(&$journal, &$result)); return $result; }
/** * Provides a hook against the validate() method in the RegistrationForm class. * This function initiates a curl() call to the Stop Forum Spam API and submits * the new user data for querying. If there is a positive match, the method * inserts a form validation error and returns true, preventing the form from * validating successfully. * * The first element in the $params array is the form object being submitted. * * @param $hookName string * @param $params Array * @return boolean */ function validateExecute($hookName, $params) { $form =& $params[0]; // Prepare HTTP session. $curlCh = curl_init(); curl_setopt($curlCh, CURLOPT_RETURNTRANSFER, true); // assemble the URL with our parameters. $url = STOP_FORUM_SPAM_API_ENDPOINT; $journal =& Request::getJournal(); $journalId = $journal->getId(); // By including all three possibilities in the URL, we always get an XML document back from the API call. $ip = (bool) $this->getSetting($journalId, 'checkIp') ? urlencode(Request::getRemoteAddr()) : ''; $url .= 'ip=' . $ip . '&'; $email = (bool) $this->getSetting($journalId, 'checkEmail') ? urlencode($form->getData('email')) : ''; $url .= 'email=' . $email . '&'; $username = (bool) $this->getSetting($journalId, 'checkUsername') ? urlencode($form->getData('username')) : ''; $url .= 'username='******'t important which parameter matches. Parameters that are // empty always produce <appears>no</appears> elements. if (preg_match('/<appears>yes<\\/appears>/', $response)) { $form->addError(__('plugins.generic.stopForumSpam.checkName'), __('plugins.generic.stopForumSpam.checkMessage')); return true; } return false; }
/** * Checks if remote client domain or ip is allowed * @return bool */ function registeredDomain(&$schedConf) { $schedConf =& Request::getSchedConf(); $registrationDao = DAORegistry::getDAO('RegistrationDAO'); $result = $registrationDao->isValidRegistration(Request::getRemoteDomain(), Request::getRemoteAddr(), null, $schedConf->getId()); HookRegistry::call('SchedConfAction::registeredDomain', array(&$schedConf, &$result)); return $result; }
/** * Insert a new log entry. * @param $entry ArticleEventLogEntry */ function insertLogEntry(&$entry) { if ($entry->getDateLogged() == null) { $entry->setDateLogged(Core::getCurrentDate()); } if ($entry->getIPAddress() == null) { $entry->setIPAddress(Request::getRemoteAddr()); } $this->update(sprintf('INSERT INTO article_event_log (article_id, user_id, date_logged, ip_address, log_level, event_type, assoc_type, assoc_id, message) VALUES (?, ?, %s, ?, ?, ?, ?, ?, ?)', $this->datetimeToDB($entry->getDateLogged())), array($entry->getArticleId(), $entry->getUserId(), $entry->getIPAddress(), $entry->getLogLevel(), $entry->getEventType(), $entry->getAssocType(), $entry->getAssocId(), $entry->getMessage())); $entry->setId($this->getInsertLogId()); return $entry->getId(); }
/** * Send the email. * @return boolean */ function send() { $recipients = $this->getRecipientString(); $from = $this->getFromString(); $subject = String::encode_mime_header($this->getSubject()); $body = $this->getBody(); // FIXME Some *nix mailers won't work with CRLFs if (Core::isWindows()) { // Convert LFs to CRLFs for Windows $body = String::regexp_replace("/([^\r]|^)\n/", "\$1\r\n", $body); } else { // Convert CRLFs to LFs for *nix $body = String::regexp_replace("/\r\n/", "\n", $body); } if ($this->getContentType() != null) { $this->addHeader('Content-Type', $this->getContentType()); } elseif ($this->hasAttachments()) { // Only add MIME headers if sending an attachment $mimeBoundary = '==boundary_' . md5(microtime()); /* Add MIME-Version and Content-Type as headers. */ $this->addHeader('MIME-Version', '1.0'); $this->addHeader('Content-Type', 'multipart/mixed; boundary="' . $mimeBoundary . '"'); } else { $this->addHeader('Content-Type', 'text/plain; charset="' . Config::getVar('i18n', 'client_charset') . '"'); } $this->addHeader('X-Mailer', 'Public Knowledge Project Suite v2'); $remoteAddr = Request::getRemoteAddr(); if ($remoteAddr != '') { $this->addHeader('X-Originating-IP', $remoteAddr); } $this->addHeader('Date', date('D, d M Y H:i:s O')); /* Add $from, $ccs, and $bccs as headers. */ if ($from != null) { $this->addHeader('From', $from); } $ccs = $this->getCcString(); if ($ccs != null) { $this->addHeader('Cc', $ccs); } $bccs = $this->getBccString(); if ($bccs != null) { $this->addHeader('Bcc', $bccs); } $headers = ''; foreach ($this->getHeaders() as $header) { if (!empty($headers)) { $headers .= MAIL_EOL; } $headers .= $header['name'] . ': ' . str_replace(array("\r", "\n"), '', $header['content']); } if ($this->hasAttachments()) { // Add the body $mailBody = 'This message is in MIME format and requires a MIME-capable mail client to view.' . MAIL_EOL . MAIL_EOL; $mailBody .= '--' . $mimeBoundary . MAIL_EOL; $mailBody .= sprintf('Content-Type: text/plain; charset=%s', Config::getVar('i18n', 'client_charset')) . MAIL_EOL . MAIL_EOL; $mailBody .= wordwrap($body, MAIL_WRAP, MAIL_EOL) . MAIL_EOL . MAIL_EOL; // Add the attachments $attachments = $this->getAttachments(); foreach ($attachments as $attachment) { $mailBody .= '--' . $mimeBoundary . MAIL_EOL; $mailBody .= 'Content-Type: ' . str_replace('"', '', $attachment['filename']) . '; name="' . $attachment['filename'] . '"' . MAIL_EOL; $mailBody .= 'Content-transfer-encoding: base64' . MAIL_EOL; $mailBody .= 'Content-disposition: ' . $attachment['disposition'] . MAIL_EOL . MAIL_EOL; $mailBody .= $attachment['content'] . MAIL_EOL . MAIL_EOL; } $mailBody .= '--' . $mimeBoundary . '--'; } else { // Just add the body $mailBody = wordwrap($body, MAIL_WRAP, MAIL_EOL); } if ($this->getEnvelopeSender() != null) { $additionalParameters = '-f ' . $this->getEnvelopeSender(); } else { $additionalParameters = null; } if (HookRegistry::call('Mail::send', array(&$this, &$recipients, &$subject, &$mailBody, &$headers, &$additionalParameters))) { return; } // Replace all the private parameters for this message. if (is_array($this->privateParams)) { foreach ($this->privateParams as $name => $value) { $mailBody = str_replace($name, $value, $mailBody); } } if (Config::getVar('email', 'smtp')) { $smtp =& Registry::get('smtpMailer', true, null); if ($smtp === null) { import('lib.pkp.classes.mail.SMTPMailer'); $smtp = new SMTPMailer(); } $sent = $smtp->mail($this, $recipients, $subject, $mailBody, $headers); } else { $sent = String::mail($recipients, $subject, $mailBody, $headers, $additionalParameters); } if (!$sent) { if (Config::getVar('debug', 'display_errors')) { if (Config::getVar('email', 'smtp')) { fatalError("There was an error sending this email. Please check your PHP error log for more information."); return false; } else { fatalError("There was an error sending this email. Please check your mail log (/var/log/maillog)."); return false; } } else { return false; } } else { return true; } }
/** * Send the email. * @return boolean */ function send() { if (HookRegistry::call('Mail::send', array($this))) { return; } // Replace all the private parameters for this message. $mailBody = $this->getBody(); if (is_array($this->privateParams)) { foreach ($this->privateParams as $name => $value) { $mailBody = str_replace($name, $value, $mailBody); } } require_once 'lib/pkp/lib/vendor/phpmailer/phpmailer/class.phpmailer.php'; $mailer = new PHPMailer(); $mailer->IsHTML(true); if (Config::getVar('email', 'smtp')) { $mailer->IsSMTP(); $mailer->Port = Config::getVar('email', 'smtp_port'); if (($s = Config::getVar('email', 'smtp_auth')) != '') { $mailer->SMTPSecure = $s; $mailer->SMTPAuth = true; } $mailer->Host = Config::getVar('email', 'smtp_server'); $mailer->Username = Config::getVar('email', 'smtp_username'); $mailer->Password = Config::getVar('email', 'smtp_password'); } $mailer->CharSet = Config::getVar('i18n', 'client_charset'); if (($t = $this->getContentType()) != null) { $mailer->ContentType = $t; } $mailer->XMailer = 'Public Knowledge Project Suite v2'; $mailer->WordWrap = MAIL_WRAP; foreach ((array) $this->getHeaders() as $header) { $mailer->AddCustomHeader($header['key'], $mailer->SecureHeader($header['content'])); } if (($s = $this->getEnvelopeSender()) != null) { $mailer->Sender = $s; } if (($f = $this->getFrom()) != null) { $mailer->SetFrom($f['email'], $f['name']); } if (($r = $this->getReplyTo()) != null) { $mailer->AddReplyTo($r['email'], $r['name']); } foreach ((array) $this->getRecipients() as $recipientInfo) { $mailer->AddAddress($recipientInfo['email'], $recipientInfo['name']); } foreach ((array) $this->getCcs() as $ccInfo) { $mailer->AddCC($ccInfo['email'], $ccInfo['name']); } foreach ((array) $this->getBccs() as $bccInfo) { $mailer->AddBCC($bccInfo['email'], $bccInfo['name']); } $mailer->Subject = $this->getSubject(); $mailer->Body = $mailBody; $mailer->AltBody = PKPString::html2text($mailBody); $remoteAddr = $mailer->SecureHeader(Request::getRemoteAddr()); if ($remoteAddr != '') { $mailer->AddCustomHeader("X-Originating-IP: {$remoteAddr}"); } foreach ((array) $this->getAttachments() as $attachmentInfo) { $mailer->AddAttachment($attachmentInfo['path'], $attachmentInfo['filename'], 'base64', $attachmentInfo['content-type']); } try { $mailer->Send(); } catch (phpmailerException $e) { error_log($mailer->ErrorInfo); return false; } return true; }
/** * Insert a new log entry. * @param $entry ConferenceEventLogEntry */ function insertLogEntry(&$entry) { if ($entry->getDateLogged() == null) { $entry->setDateLogged(Core::getCurrentDate()); } if ($entry->getIPAddress() == null) { $entry->setIPAddress(Request::getRemoteAddr()); } $this->update(sprintf('INSERT INTO conference_event_log (conference_id, sched_conf_id, user_id, date_logged, ip_address, log_level, event_type, assoc_type, assoc_id, is_translated, entry_params, message) VALUES (?, ?, ?, %s, ?, ?, ?, ?, ?, ?, ?, ?)', $this->datetimeToDB($entry->getDateLogged())), array($entry->getConferenceId(), $entry->getSchedConfId(), $entry->getUserId(), $entry->getIPAddress(), $entry->getLogLevel(), $entry->getEventType(), $entry->getAssocType(), $entry->getAssocId(), 1, $entry->getEntryParamsSerialized(), $entry->getMessage())); $entry->setLogId($this->getInsertLogId()); return $entry->getLogId(); }