Ejemplo n.º 1
0
 public function save_settings()
 {
     if (isset($_POST['alternate'])) {
         PHPWS_Cookie::write('layout_style', $_POST['alternate']);
         return TRUE;
     }
 }
Ejemplo n.º 2
0
function check_cookie()
{
    $cookie = PHPWS_Cookie::read('cookie_enabled');
    if (!$cookie) {
        if (!isset($_GET['cc'])) {
            PHPWS_Cookie::write('cookie_enabled', 'y');
            PHPWS_Core::reroute('index.php?cc=1');
        } else {
            $tpl['MESSAGE'] = dgettext('layout', 'This site requires you to enable cookies on your browser.');
            $message = PHPWS_Template::process($tpl, 'layout', 'no_cookie.tpl');
            Layout::nakedDisplay($message);
        }
    }
}
Ejemplo n.º 3
0
 public static function rememberMe()
 {
     // User must authorize locally
     if (PHPWS_Settings::get('users', 'allow_remember') && $_SESSION['User']->authorize == 1) {
         if (isset($_POST['remember_me'])) {
             $db = new PHPWS_DB('user_authorization');
             $db->addColumn('password');
             $db->addWhere('username', $_SESSION['User']->username);
             $password = $db->select('one');
             if (empty($password)) {
                 return false;
             } elseif (PHPWS_Error::isError($password)) {
                 PHPWS_Error::log($password);
                 return false;
             }
             $remember['username'] = $_SESSION['User']->username;
             $remember['password'] = $password;
             $time_to_live = time() + 86400 * REMEMBER_ME_LIFE;
             PHPWS_Cookie::write('remember_me', serialize($remember), $time_to_live);
         } else {
             PHPWS_Cookie::delete('remember_me');
         }
     }
 }
Ejemplo n.º 4
0
 public function setSearchParameters()
 {
     $this->loadSearchParameters();
     if (isset($_GET['clear'])) {
         $this->clearSearch();
     }
     if (isset($_GET['property_name_submit'])) {
         if (!empty($_GET['property_name'])) {
             $property = preg_replace('/[^\\w\\s\\-]/', '', $_GET['property_name']);
             $property = preg_replace('/\\s{2,}/', ' ', trim($property));
             $_SESSION['roommate_search']['property'] =& $property;
         } else {
             unset($_SESSION['roommate_search']['property']);
         }
     }
     if (isset($_GET['d'])) {
         if ($_GET['d'] == 'any') {
             unset($_SESSION['roommate_search']['distance']);
         } else {
             $_SESSION['roommate_search']['distance'] = $_GET['d'];
         }
     }
     if (isset($_GET['p'])) {
         if ($_GET['p'] == 'any') {
             unset($_SESSION['roommate_search']['price']);
         } else {
             if (strstr($_GET['p'], '-')) {
                 list($min, $max) = explode('-', $_GET['p']);
                 $_SESSION['roommate_search']['price']['min'] = (int) $min;
                 $_SESSION['roommate_search']['price']['max'] = (int) $max;
             }
         }
     }
     if (isset($_GET['beds'])) {
         $_SESSION['roommate_search']['beds'] = $_GET['beds'];
     }
     if (isset($_GET['bath'])) {
         $_SESSION['roommate_search']['bath'] = $_GET['bath'];
     }
     if (isset($_GET['amen'])) {
         $_SESSION['roommate_search']['amenities'][$_GET['amen']] = 1;
     }
     if (isset($_GET['nosub'])) {
         unset($_SESSION['roommate_search']['sub']);
         $_SESSION['roommate_search']['nosub'] = 1;
     }
     if (isset($_GET['sub'])) {
         $_SESSION['roommate_search']['sub'] = 1;
         unset($_SESSION['roommate_search']['nosub']);
     }
     if (isset($_GET['gen'])) {
         $_SESSION['roommate_search']['gen'] = $_GET['gen'];
     }
     if (isset($_GET['smoke'])) {
         $_SESSION['roommate_search']['smoke'] = $_GET['smoke'];
     }
     \PHPWS_Cookie::write('roommate_search', serialize($_SESSION['roommate_search']));
 }
Ejemplo n.º 5
0
 public static function getUserType()
 {
     if ($user_type = PHPWS_Cookie::read('phpws_editor')) {
         if ($user_type == 'none') {
             return null;
         }
         // prevent shenanigans
         if (preg_match('/\\W/', $user_type)) {
             return DEFAULT_EDITOR_TOOL;
         }
         if (Editor::isType($user_type)) {
             return $user_type;
         } else {
             PHPWS_Cookie::delete('phpws_editor');
         }
     }
     return DEFAULT_EDITOR_TOOL;
 }
Ejemplo n.º 6
0
 public function loadStyleSheets($themeVars)
 {
     $this->_extra_styles = null;
     $this->_style_sheets = null;
     $directory = sprintf('themes/%s/', $this->current_theme);
     @($cookie = PHPWS_Cookie::read('layout_style'));
     for ($i = 1; $i < 20; $i++) {
         if (isset($themeVars['style_sheet_' . $i])) {
             $style =& $themeVars['style_sheet_' . $i];
             $style_file = $style['file'];
             $style['file'] = $directory . $style['file'];
             // If the cookie is set, the alternate style sheet then becomes
             // a primary. The primary becomes an alternate.
             if ($cookie && is_file($directory . $cookie)) {
                 if (isset($style['title'])) {
                     if ($cookie == $style_file) {
                         $style['alternate'] = false;
                     } else {
                         $style['alternate'] = true;
                     }
                 }
             }
             $this->_style_sheets[] = $style;
         } else {
             break;
         }
     }
     if (isset($themeVars['extra_styles'])) {
         $this->_extra_styles =& $themeVars['extra_styles'];
     }
 }
Ejemplo n.º 7
0
 public function hidePanelLink()
 {
     if (PHPWS_Cookie::read('checkin_hide_panel') || $this->use_panel == false) {
         $this->use_panel = false;
         return PHPWS_Text::moduleLink(dgettext('checkin', 'Show panel'), 'checkin', array('aop' => 'show_panel'));
     } else {
         return PHPWS_Text::moduleLink(dgettext('checkin', 'Hide panel'), 'checkin', array('aop' => 'hide_panel'));
     }
 }
Ejemplo n.º 8
0
 /**
  * Get user's timezone or the server time zone if none is
  * set
  */
 public static function getUserTZ()
 {
     $user_tz = PHPWS_Cookie::read('user_tz');
     if (!isset($user_tz)) {
         return PHPWS_Time::getServerTZ();
     } else {
         $user_dst = PHPWS_Cookie::read('user_dst');
         if (!isset($user_dst)) {
             return $user_tz;
         } else {
             return $user_tz + date('I');
         }
     }
 }
Ejemplo n.º 9
0
 public static function rememberLogin()
 {
     if (!isset($_SESSION['User'])) {
         return false;
     }
     $remember = PHPWS_Cookie::read('remember_me');
     if (!$remember) {
         return false;
     }
     $rArray = @unserialize($remember);
     if (!is_array($rArray)) {
         return false;
     }
     if (!isset($rArray['username']) || !isset($rArray['password'])) {
         return false;
     }
     if (preg_match('/\\W/', $rArray['password'])) {
         return false;
     }
     $username = strtolower($rArray['username']);
     if (preg_match('/\'|"/', html_entity_decode($username, ENT_QUOTES))) {
         Security::log(dgettext('users', 'User tried to login using Remember Me with a malformed cookie.'));
         return false;
     }
     $db = new PHPWS_DB('user_authorization');
     $db->addWhere('username', $username);
     $db->addWhere('password', $rArray['password']);
     $result = $db->select('row');
     if (!$result) {
         return false;
     } elseif (PHPWS_Error::isError($result)) {
         PHPWS_Error::log($result);
         return false;
     }
     $db2 = new PHPWS_DB('users');
     $db2->addWhere('username', $username);
     $db2->addWhere('approved', 1);
     $db2->addWhere('active', 1);
     if (!ALLOW_DEITY_REMEMBER_ME) {
         $db2->addWhere('deity', 0);
     }
     $result = $db2->loadObject($_SESSION['User']);
     if (!$result) {
         return false;
     } elseif (PHPWS_Error::isError($result)) {
         PHPWS_Error::log($result);
         return false;
     }
     $_SESSION['User']->login();
     return true;
 }