Example #1
0
 private function onVote(GWF_VoteMulti $poll, $user)
 {
     $opts = Common::getPostArray('opt', array());
     $taken = array();
     $max = $poll->getNumChoices();
     foreach ($opts as $i => $stub) {
         $i = (int) $i;
         if ($i < 1 || $i > $max) {
             continue;
         }
         if (!in_array($i, $taken, true)) {
             $taken[] = $i;
         }
     }
     $count = count($taken);
     //		if ($count === 0) {
     //			return $this->module->error('err_no_options');
     //		}
     if (!$poll->isMultipleChoice() && $count !== 1) {
         return $this->module->error('err_no_multi');
     }
     if (false === $poll->onVote($user, $taken)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_voted', array(htmlspecialchars(GWF_Session::getLastURL())));
 }
Example #2
0
 public function execute()
 {
     if (false === ($user = GWF_Session::getUser()) && !$this->module->cfgGuestShouts()) {
         return GWF_HTML::err('ERR_LOGIN_REQUIRED');
     }
     if ($user !== false && $user->isWebspider()) {
         return GWF_HTML::err('ERR_NO_PERMISSION');
     }
     if (false !== ($error = $this->isFlooding())) {
         return $error;
     }
     $message = Common::getPost('message', '');
     if (false !== ($error = $this->validate_message($message))) {
         return GWF_HTML::error('Shoutbox', $error);
     }
     $entry = new GWF_Shoutbox(array('shout_id' => '0', 'shout_uid' => GWF_Session::getUserID(), 'shout_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'shout_uname' => GWF_Shoutbox::generateUsername(), 'shout_message' => $message));
     if (false === $entry->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if ($this->module->cfgEMailModeration()) {
         $this->onEMailModeration($user, $entry);
     }
     $url = htmlspecialchars(GWF_Session::getLastURL());
     return $this->module->message('msg_shouted', array($url, $url));
 }
Example #3
0
 public static function redirectBack()
 {
     $url = GWF_WEB_ROOT;
     if (false !== ($url2 = GWF_Session::getLastURL())) {
         $url = GWF_WEB_ROOT . ltrim($url2, '/');
     }
     self::redirect($url);
 }
Example #4
0
 public function execute(GWF_Module $module)
 {
     if (GWF_Session::haveCookies()) {
         GWF_Session::set(GWF_Browser::SESS_DETECTION, 1);
         GWF_Session::set(GWF_Browser::SESS_RESOLUTION, array(intval(Common::getGet('w', -1)), intval(Common::getGet('h', -1))));
         GWF_Website::redirectBack();
     } else {
         $url = Common::getGet('url', GWF_Session::getLastURL());
         if ($module->cfgFallbackSessions()) {
             GWF_Session::createFallback($url);
             GWF_Website::redirect(GWF_WEB_ROOT . 'index.php?mo=GWF&me=CookieCheck&level=2&url=' . urlencode($url));
         } else {
             GWF_Website::redirectBack();
         }
     }
 }
Example #5
0
 public function execute(GWF_Module $module)
 {
     $url = Common::getGet('url', GWF_Session::getLastURL());
     switch (Common::getGet('level')) {
         case '1':
             if (GWF_Session::haveCookies() === true) {
                 GWF_Website::redirectBack();
             } elseif ($module->cfgFallbackSessions()) {
                 GWF_Session::createFallback($url);
                 GWF_Website::redirect(GWF_WEB_ROOT . 'index.php?mo=GWF&me=CookieCheck&level=2&url=' . urlencode($url));
             } else {
                 GWF_Website::redirect($url);
             }
             break;
         case '2':
             //				var_dump($_SERVER);
             GWF_Website::redirect($url);
             break;
         default:
             return GWF_HTML::err('ERR_PARAMETER', array(__FILE__, __LINE__, 'level'));
     }
 }
Example #6
0
 private function onLoggedIn(GWF_User $user, $isAjax)
 {
     $last_url = GWF_Session::getLastURL();
     if (false === GWF_Session::onLogin($user, isset($_POST['bind_ip']))) {
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     require_once GWF_CORE_PATH . 'module/Login/GWF_LoginHistory.php';
     GWF_LoginHistory::insertEvent($user->getID());
     # save last login time
     $user->saveVar('user_lastlogin', time());
     if ($this->module->cfgCleanupAlways()) {
         GWF_LoginFailure::cleanupUser($user->getID());
     }
     if ($isAjax) {
         return sprintf('1:%s', GWF_Session::getSessID());
     } else {
         GWF_Session::set('GWF_LOGIN_BACK', $last_url);
         if (false !== ($lang = $user->getLanguage())) {
             GWF_Language::setCurrentLanguage($lang);
         }
         if (0 < ($fails = GWF_LoginFailure::getFailCount($user, $this->module->cfgTryExceed()))) {
             GWF_Session::set('GWF_LOGIN_FAILS', $fails);
         }
         GWF_Website::redirect(GWF_WEB_ROOT . 'welcome');
     }
 }
Example #7
0
 private function onVoted($user)
 {
     GWF_Hook::call(GWF_Hook::VOTED_SCORE, $user, array($this->votescore->getID(), $this->score));
     return isset($_GET['ajax']) ? $this->module->message('msg_voted_ajax') : $this->module->message('msg_voted', array(GWF_Session::getLastURL()));
 }