function getConfigFilename()
 {
     $variablesScriptPath = $this->installPath . '/variables.php';
     if (!file_exists($variablesScriptPath)) {
         return null;
     }
     require_once $variablesScriptPath;
     return $this->installPath . '/var/' . Request::getServerHost() . '.conf.php';
 }
Example #2
0
 /**
  * Change the locale for the current user.
  * @param $args array first parameter is the new locale
  */
 function setLocale($args)
 {
     $setLocale = isset($args[0]) ? $args[0] : null;
     $site =& Request::getSite();
     if (Locale::isLocaleValid($setLocale) && in_array($setLocale, $site->getSupportedLocales())) {
         $session =& Request::getSession();
         $session->setSessionVar('currentLocale', $setLocale);
     }
     if (isset($_SERVER['HTTP_REFERER'])) {
         Request::redirectUrl($_SERVER['HTTP_REFERER']);
     }
     $source = Request::getUserVar('source');
     if (isset($source) && !empty($source)) {
         Request::redirectUrl(Request::getProtocol() . '://' . Request::getServerHost() . $source, false);
     }
     Request::redirect(null, 'index');
 }
Example #3
0
 /**
  * Validate a user's credentials and log the user in.
  */
 function signIn()
 {
     parent::validate();
     if (Validation::isLoggedIn()) {
         Request::redirect(null, 'user');
     }
     if (Config::getVar('security', 'force_login_ssl') && Request::getProtocol() != 'https') {
         // Force SSL connections for login
         Request::redirectSSL();
     }
     $user = Validation::login(Request::getUserVar('username'), Request::getUserVar('password'), $reason, Request::getUserVar('remember') == null ? false : true);
     if ($user !== false) {
         if (Config::getVar('security', 'force_login_ssl') && !Config::getVar('security', 'force_ssl')) {
             // Redirect back to HTTP if forcing SSL for login only
             Request::redirectNonSSL();
         } else {
             if ($user->getMustChangePassword()) {
                 // User must change their password in order to log in
                 Validation::logout();
                 Request::redirect(null, null, 'changePassword', $user->getUsername());
             } else {
                 $source = Request::getUserVar('source');
                 if (isset($source) && !empty($source)) {
                     Request::redirectUrl(Request::getProtocol() . '://' . Request::getServerHost() . $source, false);
                 } else {
                     Request::redirect(null, 'user');
                 }
             }
         }
     } else {
         $sessionManager =& SessionManager::getManager();
         $session =& $sessionManager->getUserSession();
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->assign('username', Request::getUserVar('username'));
         $templateMgr->assign('remember', Request::getUserVar('remember'));
         $templateMgr->assign('source', Request::getUserVar('source'));
         $templateMgr->assign('showRemember', Config::getVar('general', 'session_lifetime') > 0);
         $templateMgr->assign('error', $reason === null ? 'user.login.loginError' : ($reason === '' ? 'user.login.accountDisabled' : 'user.login.accountDisabledWithReason'));
         $templateMgr->assign('reason', $reason);
         $templateMgr->display('user/login.tpl');
     }
 }
Example #4
0
 /**
  * Get the complete URL of the request.
  * @return string
  */
 function getRequestUrl()
 {
     static $requestUrl;
     if (!isset($requestUrl)) {
         $requestUrl = Request::getProtocol() . '://' . Request::getServerHost() . Request::getRequestPath();
         HookRegistry::call('Request::getRequestUrl', array(&$requestUrl));
     }
     return $requestUrl;
 }
Example #5
0
 /**
  * Send mail.
  * @param $mail Mailer
  * @param $recipients string
  * @param $subject string
  * @param $body string
  * @param $headers string
  */
 function mail(&$mail, $recipients, $subject, $body, $headers = '')
 {
     // Establish connection
     if (!$this->connect()) {
         return false;
     }
     if (!$this->receive('220')) {
         return $this->disconnect('Did not receive expected 220');
     }
     // Send HELO/EHLO command
     if (!$this->send($this->auth ? 'EHLO' : 'HELO', Request::getServerHost())) {
         return $this->disconnect('Could not send HELO/HELO');
     }
     if (!$this->receive('250')) {
         return $this->disconnect('Did not receive expected 250 (1)');
     }
     if ($this->auth) {
         // Perform authentication
         if (!$this->authenticate()) {
             return $this->disconnect('Could not authenticate');
         }
     }
     // Send MAIL command
     $sender = $mail->getEnvelopeSender();
     if (!isset($sender) || empty($sender)) {
         $from = $mail->getFrom();
         if (isset($from['email']) && !empty($from['email'])) {
             $sender = $from['email'];
         } else {
             $sender = get_current_user() . '@' . Request::getServerHost();
         }
     }
     if (!$this->send('MAIL', 'FROM:<' . $sender . '>')) {
         return $this->disconnect('Could not send sender');
     }
     if (!$this->receive('250')) {
         return $this->disconnect('Did not receive expected 250 (2)');
     }
     // Send RCPT command(s)
     $rcpt = array();
     if (($addrs = $mail->getRecipients()) !== null) {
         $rcpt = array_merge($rcpt, $addrs);
     }
     if (($addrs = $mail->getCcs()) !== null) {
         $rcpt = array_merge($rcpt, $addrs);
     }
     if (($addrs = $mail->getBccs()) !== null) {
         $rcpt = array_merge($rcpt, $addrs);
     }
     foreach ($rcpt as $addr) {
         if (!$this->send('RCPT', 'TO:<' . $addr['email'] . '>')) {
             return $this->disconnect('Could not send recipients');
         }
         if (!$this->receive(array('250', '251'))) {
             return $this->disconnect('Did not receive expected 250 or 251');
         }
     }
     // Send headers and body
     if (!$this->send('DATA')) {
         return $this->disconnect('Could not send DATA');
     }
     if (!$this->receive('354')) {
         return $this->disconnect('Did not receive expected 354');
     }
     if (!$this->send('To:', empty($recipients) ? 'undisclosed-recipients:;' : $recipients)) {
         return $this->disconnect('Could not send recipients (2)');
     }
     if (!$this->send('Subject:', $subject)) {
         return $this->disconnect('Could not send subject');
     }
     $lines = explode(MAIL_EOL, $headers);
     for ($i = 0, $num = count($lines); $i < $num; $i++) {
         if (preg_match('/^bcc:/i', $lines[$i])) {
             continue;
         }
         if (!$this->send($lines[$i])) {
             return $this->disconnect('Could not send headers');
         }
     }
     if (!$this->send('')) {
         return $this->disconnect('Could not send CR');
     }
     $lines = explode(MAIL_EOL, $body);
     for ($i = 0, $num = count($lines); $i < $num; $i++) {
         if (substr($lines[$i], 0, 1) == '.') {
             $lines[$i] = '.' . $lines[$i];
         }
         if (!$this->send($lines[$i])) {
             return $this->disconnect('Could not send body');
         }
     }
     // Mark end of data
     if (!$this->send('.')) {
         return $this->disconnect('Could not send EOT');
     }
     if (!$this->receive('250')) {
         return $this->disconnect('Did not receive expected 250 (3)');
     }
     // Tear down connection
     return $this->disconnect();
 }
 /**
  * Log a user out.
  */
 function signOut()
 {
     $this->validate();
     $this->setupTemplate();
     if (Validation::isLoggedIn()) {
         Validation::logout();
     }
     $source = Request::getUserVar('source');
     if (isset($source) && !empty($source)) {
         PKPRequest::redirectUrl(Request::getProtocol() . '://' . Request::getServerHost() . $source, false);
     } else {
         PKPRequest::redirect(null, Request::getRequestedPage());
     }
 }
 function OjsAnnotationService()
 {
     $servicePath = Request::getRequestUrl();
     $host = Request::getServerHost();
     // Get install date.  Seems to produce 1969-12-31
     $versionDao =& DAORegistry::getDAO('VersionDAO');
     $versions =& $versionDao->getVersionHistory();
     $firstVersion = array_pop($versions);
     $installDate = $firstVersion->getDateInstalled();
     $installDate = strtotime($installDate);
     $username = Request::getUser();
     if ($username) {
         $username = $username->getUsername();
     }
     $sessionManager =& SessionManager::getManager();
     $session = $sessionManager->getUserSession();
     AnnotationService::AnnotationService($host, $servicePath, $installDate, $username, array('csrfCookie' => Config::getVar('general', 'session_cookie_name'), 'csrfCookieValue' => $session->getId()));
 }
Example #8
0
 /**
  * Initialize form data.
  */
 function initData()
 {
     $cwd = getcwd();
     if (Core::isWindows()) {
         // Replace backslashes with slashes for the default files directory.
         $cwd = str_replace('\\', '/', $cwd);
     }
     $this->_data = array('locale' => Locale::getLocale(), 'additionalLocales' => array(), 'clientCharset' => 'utf-8', 'connectionCharset' => '', 'databaseCharset' => '', 'encryption' => 'md5', 'filesDir' => $cwd . '/files', 'skipFilesDir' => 0, 'databaseDriver' => 'mysql', 'databaseHost' => 'localhost', 'databaseUsername' => 'ojs', 'databasePassword' => '', 'databaseName' => 'ojs', 'createDatabase' => 1, 'oaiRepositoryId' => 'ojs.' . Request::getServerHost());
 }
Example #9
0
 /**
  * Initialize form data.
  */
 function initData()
 {
     $docRoot = dirname($_SERVER['DOCUMENT_ROOT']);
     if (Core::isWindows()) {
         // Replace backslashes with slashes for the default files directory.
         $docRoot = str_replace('\\', '/', $docRoot);
     }
     // Add a trailing slash for paths that aren't filesystem root
     if ($docRoot !== '/') {
         $docRoot .= '/';
     }
     $this->_data = array('locale' => AppLocale::getLocale(), 'additionalLocales' => array(), 'clientCharset' => 'utf-8', 'connectionCharset' => '', 'databaseCharset' => '', 'encryption' => 'md5', 'filesDir' => $docRoot . 'files', 'databaseDriver' => 'mysql', 'databaseHost' => 'localhost', 'databaseUsername' => 'ojs', 'databasePassword' => '', 'databaseName' => 'ojs', 'createDatabase' => 1, 'oaiRepositoryId' => 'ojs.' . Request::getServerHost());
 }