private function set_funnycookie()
 {
     global $funnyquestion_hash, $funnyquestion_remember;
     $time = time();
     forum_setcookie('funnyquestion_hash', sha1($time . get_remote_address() . $funnyquestion_hash), $time + $funnyquestion_remember);
     forum_setcookie('funnyquestion_time', $time, $time + $funnyquestion_remember);
 }
示例#2
0
    function setRead_items_cookie($status, $items)
    {
	    $cookie_name = "LF";
		$items = array();
		if(!empty($status)):
		$item_handler =& xoops_getmodulehandler('forum', 'xforum');
		$items_id = $item_handler->getIds();
		foreach($items_id as $key){
			$items[$key] = time();
		}
		endif;
		forum_setcookie($cookie_name, $items);
		return true;
    }
 function hook_register_before_header()
 {
     global $required_fields, $errors, $cookie_name, $cookie_seed;
     $this->load_lang();
     $required_fields['req_word'] = $this->lang['Captcha'];
     $time = time();
     $word = random_pass(mt_rand(4, 6));
     $hash = sha1(strtolower($word) . $cookie_seed . 'secret' . $time);
     forum_setcookie($cookie_name . '_captcha', $hash . '-' . $time, $time + 120);
     $array = str_split($word);
     $mixin = random_pass(mt_rand(1, 3));
     $i = -1;
     $this->styles = '';
     foreach (str_split($mixin) as $ch) {
         $i = mt_rand($i + 1, count($array));
         array_splice($array, $i, 0, $ch);
         $this->styles .= '.masq i:nth-child(' . ($i + 1) . '){display:none;} ';
     }
     $this->spans = '<i>' . implode('</i><i>', $array) . '</i>';
 }
示例#4
0
$perm =& xoops_getmodulehandler('permission', 'xforum');
$permission_set = $perm->getPermissions('forum', $forum_id);

if (!$topic_handler->getPermission($viewtopic_forum, $xforumtopic->getVar('topic_status'), "view")){
    redirect_header("viewforum.php?forum=".$forum_id, 2, _MD_NORIGHTTOVIEW);
    exit();
}

$karma_handler =& xoops_getmodulehandler('karma', 'xforum');
$user_karma = $karma_handler->getUserKarma();

$valid_modes = array("flat", "thread", "compact");
$viewmode_cookie = forum_getcookie("V");
if(isset($_GET['viewmode']) && in_array($_GET['viewmode'], $valid_modes)) {
	forum_setcookie("V", $_GET['viewmode'], $forumCookie['expire']);
}
$viewmode = isset($_GET['viewmode'])? $_GET['viewmode'] : 
			(
				!empty($viewmode_cookie)?
				$viewmode_cookie:
				(
			/*
					is_object($xoopsUser)?
					$xoopsUser->getVar('umode'):
			*/
					@$valid_modes[$xoopsModuleConfig['view_mode']-1]
				)
			);
$viewmode = in_array($viewmode, $valid_modes)?$viewmode:"flat";
$order = (isset($_GET['order']) && in_array(strtoupper($_GET['order']),array("DESC","ASC")))?$_GET['order']:"ASC";
function set_tracked_topics($tracked_topics)
{
    global $cookie_name, $cookie_path, $cookie_domain, $cookie_secure, $forum_config;
    $return = ($hook = get_hook('fn_set_tracked_topics_start')) ? eval($hook) : null;
    if ($return != null) {
        return;
    }
    $cookie_data = '';
    if (!empty($tracked_topics)) {
        // Sort the arrays (latest read first)
        arsort($tracked_topics['topics'], SORT_NUMERIC);
        arsort($tracked_topics['forums'], SORT_NUMERIC);
        // Homebrew serialization (to avoid having to run unserialize() on cookie data)
        foreach ($tracked_topics['topics'] as $id => $timestamp) {
            $cookie_data .= 't' . $id . '=' . $timestamp . ';';
        }
        foreach ($tracked_topics['forums'] as $id => $timestamp) {
            $cookie_data .= 'f' . $id . '=' . $timestamp . ';';
        }
        // Enforce a 4048 byte size limit (4096 minus some space for the cookie name)
        if (strlen($cookie_data) > 4048) {
            $cookie_data = substr($cookie_data, 0, 4048);
            $cookie_data = substr($cookie_data, 0, strrpos($cookie_data, ';')) . ';';
        }
    }
    forum_setcookie($cookie_name . '_track', $cookie_data, time() + $forum_config['o_timeout_visit']);
    $_COOKIE[$cookie_name . '_track'] = $cookie_data;
    // Set it directly in $_COOKIE as well
}
示例#6
0
//  Project: X-Forum 4                                                       //
//  ------------------------------------------------------------------------ //


include_once '../../mainfile.php';
error_reporting(E_ALL);
include_once XOOPS_ROOT_PATH."/modules/".$xoopsModule->getVar("dirname")."/include/vars.php";
include_once XOOPS_ROOT_PATH."/modules/".$xoopsModule->getVar("dirname")."/include/functions.php";
include_once XOOPS_ROOT_PATH."/Frameworks/art/functions.php";

$myts =& MyTextSanitizer::getInstance();

// menumode cookie
if(isset($_REQUEST['menumode'])){
	$menumode = intval($_REQUEST['menumode']);
	forum_setcookie("M", $menumode, $forumCookie['expire']);
}else{
	$cookie_M = intval(forum_getcookie("M"));
	$menumode = ($cookie_M === null || !isset($valid_menumodes[$cookie_M]))?$xoopsModuleConfig['menu_mode']:$cookie_M;
}

$menumode_other = array();
$menu_url = htmlSpecialChars(preg_replace("/&menumode=[^&]/", "", $_SERVER[ 'REQUEST_URI' ]));
$menu_url .= (false === strpos($menu_url, "?"))?"?menumode=":"&amp;menumode=";
foreach($valid_menumodes as $key=>$val){
	if($key != $menumode) $menumode_other[]=array("title"=>$val, "link"=>$menu_url.$key);
}

$forum_module_header = '';
$forum_module_header .= '<link rel="alternate" type="application/rss+xml" title="'.$xoopsModule->getVar('name').'" href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/rss.php" />';
if(!empty($xoopsModuleConfig['pngforie_enabled'])){
function set_tracked_topics($tracked_topics)
{
    global $cookie_name, $cookie_path, $cookie_domain, $cookie_secure, $pun_config;
    $cookie_data = '';
    if (!empty($tracked_topics)) {
        // Sort the arrays (latest read first)
        arsort($tracked_topics['topics'], SORT_NUMERIC);
        arsort($tracked_topics['forums'], SORT_NUMERIC);
        // Homebrew serialization (to avoid having to run unserialize() on cookie data)
        foreach ($tracked_topics['topics'] as $id => $timestamp) {
            $cookie_data .= 't' . $id . '=' . $timestamp . ';';
        }
        foreach ($tracked_topics['forums'] as $id => $timestamp) {
            $cookie_data .= 'f' . $id . '=' . $timestamp . ';';
        }
        // Enforce a byte size limit (4096 minus some space for the cookie name - defaults to 4048)
        if (strlen($cookie_data) > FORUM_MAX_COOKIE_SIZE) {
            $cookie_data = substr($cookie_data, 0, FORUM_MAX_COOKIE_SIZE);
            $cookie_data = substr($cookie_data, 0, strrpos($cookie_data, ';')) . ';';
        }
    }
    forum_setcookie($cookie_name . '_track', $cookie_data, time() + $pun_config['o_timeout_visit']);
    $_COOKIE[$cookie_name . '_track'] = $cookie_data;
    // Set it directly in $_COOKIE as well
}
示例#8
0
        */
		break;
	default:
		$criteria_type_count = new Criteria("approved", 1);
		$criteria_type_post = new Criteria("p.approved", 1);
		break;
}
$criteria_count->add($criteria_type_count);
$criteria_post->add($criteria_type_post);

$karma_handler =& xoops_getmodulehandler('karma', 'xforum');
$user_karma = $karma_handler->getUserKarma();

$valid_modes = array("flat", "compact");
$viewmode_cookie = forum_getcookie("V");
if(isset($_GET['viewmode'])&&$_GET['viewmode']=="compact") forum_setcookie("V", "compact", $forumCookie['expire']);
$viewmode = isset($_GET['viewmode'])?
			$_GET['viewmode']:
			(
				!empty($viewmode_cookie)?
				$viewmode_cookie:
				(
				/*
					is_object($xoopsUser)?
					$xoopsUser->getVar('umode'):
				*/
					@$valid_modes[$xoopsModuleConfig['view_mode']-1]
				)
			);
$viewmode = in_array($viewmode, $valid_modes)?$viewmode:"flat";
 private function user_login($user_id, $prev_url = '')
 {
     global $forum_config, $lang_fancy_login_loginza, $forum_user, $forum_db, $cookie_name, $forum_url;
     // Load the login language file
     if (!isset($lang_login)) {
         require FORUM_ROOT . 'lang/' . $forum_user['language'] . '/login.php';
     }
     // Get user info matching login attempt
     $query = array('SELECT' => 'u.id, u.group_id, u.password, u.salt, u.activate_key', 'FROM' => 'users AS u', 'WHERE' => 'u.id=\'' . $forum_db->escape($user_id) . '\'');
     $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
     list($user_id, $group_id, $db_password_hash, $salt, $activate_key) = $forum_db->fetch_row($result);
     //
     if ($group_id == FORUM_UNVERIFIED && !empty($activate_key)) {
         message($lang_fancy_login_loginza['Activate first']);
     }
     // Remove this user's guest entry from the online list
     $query = array('DELETE' => 'online', 'WHERE' => 'ident=\'' . $forum_db->escape(get_remote_address()) . '\'');
     ($hook = get_hook('li_login_qr_delete_online_user')) ? eval($hook) : null;
     $forum_db->query_build($query) or error(__FILE__, __LINE__);
     $expire = time() + 1209600;
     forum_setcookie($cookie_name, base64_encode($user_id . '|' . $db_password_hash . '|' . $expire . '|' . sha1($salt . $db_password_hash . forum_hash($expire, $salt))), $expire);
     ($hook = get_hook('li_login_pre_redirect')) ? eval($hook) : null;
     //if (empty($prev_url)) {
     $prev_url = forum_link($forum_url['index']);
     //}
     redirect(forum_htmlencode($prev_url) . (substr_count($prev_url, '?') == 1 ? '&amp;' : '?') . 'login=1', $lang_login['Login redirect']);
 }
示例#10
0
    function setRead_cookie($read_item, $post_id)
    {
	    $cookie_name = ($this->type == "forum") ? "LF" : "LT";
		$lastview = forum_getcookie($cookie_name, true);
		$lastview[$read_item] = time();
		forum_setcookie($cookie_name, $lastview);
    }
示例#11
0
function pun_stop_bots_set_cookie($question_id)
{
    global $forum_user, $cookie_name, $cookie_path, $cookie_domain, $cookie_secure;
    $now = time();
    $expire_time = $now + 1209600;
    $expire_hash = sha1($forum_user['salt'] . forum_hash($expire_time, $forum_user['salt']));
    $question_hash = forum_hash($question_id, $forum_user['salt']);
    forum_setcookie(PUN_STOP_BOTS_COOKIE_NAME, base64_encode($forum_user['id'] . '|' . $question_hash . '|' . $expire_time . '|' . $expire_hash), $expire_time);
}
示例#12
0
    function setRead_items_cookie($status, $forum_id)
    {
	    $cookie_name = "LT";
	    $cookie_vars = forum_getcookie($cookie_name, true);
	    
		$item_handler =& xoops_getmodulehandler('topic', 'xforum');
		$criteria =& new CriteriaCompo(new Criteria("forum_id", $forum_id));
		$criteria->setSort("topic_last_post_id");
		$criteria->setOrder("DESC");
		$criteria->setLimit($this->items_per_forum);
		$items = $item_handler->getIds($criteria);
	    
	    foreach($items as $var){
		    if(empty($status)){
			    if(isset($cookie_vars[$var])) unset($cookie_vars[$var]);
		    }else{
			    $cookie_vars[$var] = time() /*$items[$var]*/;
		    }
	    }
		forum_setcookie($cookie_name, $cookie_vars);
		return true;
    }
示例#13
0
if(empty($forumCookie['prefix'])){
	$cookie_prefix = preg_replace("/[^a-z_0-9]+/i", "_", preg_replace("/(http(s)?:\/\/)?(www.)?/i","",XOOPS_URL));
	$cookie_userid = (is_object($xoopsUser))?$xoopsUser->getVar('uid'):0;
	$forumCookie['prefix'] = $cookie_prefix."_".$xoopsModule->dirname().'_'.$cookie_userid."_";
}

// set LastVisitTemp cookie, which only gets the time from the LastVisit cookie if it does not exist yet
// otherwise, it gets the time from the LastVisitTemp cookie
//$last_visit = forum_getcookie("LVT");
$last_visit = forum_getsession("LV");
$last_visit = ($last_visit)?$last_visit:forum_getcookie("LV");
$last_visit = ($last_visit)?$last_visit:time();


// update LastVisit cookie.
forum_setcookie("LV", time(), $forumCookie['expire']); // set cookie life time to one month
//forum_setcookie("LVT", $last_visit);
forum_setsession("LV", $last_visit);

/* xforum cookie storage
	Long term cookie: (configurable, generally one month)
		LV - Last Visit
		M - Menu mode
		V - View mode
		G - Toggle
	Short term cookie: (same as session life time)
		ST - Stored Topic IDs for mark
		LP - Last Post
		LF - Forum Last view
		LT - Topic Last read
		LVT - Last Visit Temp
示例#14
0
function set_forum_login_cookie($id, $forum_password)
{
    global $panther_config;
    $cookie_data = isset($_COOKIE[$panther_config['o_cookie_name'] . '_forums']) ? $_COOKIE[$panther_config['o_cookie_name'] . '_forums'] : '';
    if (!$cookie_data || strlen($cookie_data) > FORUM_MAX_COOKIE_SIZE) {
        $cookie_data = '';
    }
    $cookie_data = unserialize($cookie_data);
    $salt = random_key(64, true);
    $cookie_hash = panther_hash($forum_password . panther_hash($salt));
    $cookie_data[$id] = array('hash' => $cookie_hash, 'salt' => $salt);
    forum_setcookie($panther_config['o_cookie_name'] . '_forums', serialize($cookie_data), time() + $panther_config['o_timeout_visit']);
    $_COOKIE[$panther_config['o_cookie_name'] . '_forums'] = serialize($cookie_data);
}
                     ($hook = get_hook('rg_register_dupe_email')) ? eval($hook) : null;
                     forum_mail($forum_config['o_mailing_list'], $mail_subject, $mail_message);
                 }
                 ($hook = get_hook('rg_register_pre_login_redirect')) ? eval($hook) : null;
                 // Must the user verify the registration or do we log him/her in right now?
                 if ($forum_config['o_regs_verify'] == '1') {
                     message(sprintf($lang_profile['Reg e-mail'], '<a href="mailto:' . forum_htmlencode($forum_config['o_admin_email']) . '">' . forum_htmlencode($forum_config['o_admin_email']) . '</a>'));
                 } else {
                     // Remove cache file with forum stats
                     if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
                         require FORUM_ROOT . 'include/cache.php';
                     }
                     clean_stats_cache();
                 }
                 $expire = time() + $forum_config['o_timeout_visit'];
                 forum_setcookie($cookie_name, base64_encode($new_uid . '|' . $password_hash . '|' . $expire . '|' . sha1($salt . $password_hash . forum_hash($expire, $salt))), $expire);
                 if (!isset($_SESSION['req_buyer_account'])) {
                     //INCREASE THE INVITED COUNTER
                     $query = array('SELECT' => 'u.invited', 'FROM' => 'users AS u', 'WHERE' => 'u.username=\'' . $forum_db->escape($username2) . '\'');
                     $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
                     $array2 = $forum_db->fetch_assoc($result);
                     $invited = $array2['invited'];
                     $invited2 = $invited + 1;
                     $query = array('UPDATE' => 'users', 'SET' => "invited='{$invited2}'", 'WHERE' => 'username=\'' . $forum_db->escape($username2) . '\'');
                     $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
                 }
                 redirect(forum_link($forum_url['index']), $lang_profile['Reg complete']);
             }
         }
     }
 }
             $authorized = true;
         }
     }
     if (!$authorized) {
         $errors[] = $lang_profile['Wrong old password'];
     }
     // Did everything go according to plan?
     if (empty($errors)) {
         $new_password_hash = forum_hash($new_password1, $user['salt']);
         $query = array('UPDATE' => 'users', 'SET' => 'password=\'' . $new_password_hash . '\'', 'WHERE' => 'id=' . $id);
         ($hook = get_hook('pf_change_pass_normal_qr_update_password')) ? eval($hook) : null;
         $forum_db->query_build($query) or error(__FILE__, __LINE__);
         if ($forum_user['id'] == $id) {
             $cookie_data = @explode('|', base64_decode($_COOKIE[$cookie_name]));
             $expire = $cookie_data[2] > time() + $forum_config['o_timeout_visit'] ? time() + 1209600 : time() + $forum_config['o_timeout_visit'];
             forum_setcookie($cookie_name, base64_encode($forum_user['id'] . '|' . $new_password_hash . '|' . $expire . '|' . sha1($user['salt'] . $new_password_hash . forum_hash($expire, $user['salt']))), $expire);
         }
         // Add flash message
         $forum_flash->add_info($lang_profile['Pass updated redirect']);
         ($hook = get_hook('pf_change_pass_normal_pre_redirect')) ? eval($hook) : null;
         redirect(forum_link($forum_url['profile_about'], $id), $lang_profile['Pass updated redirect']);
     }
 }
 // Is this users own profile
 $forum_page['own_profile'] = $forum_user['id'] == $id ? true : false;
 // Setup form
 $forum_page['group_count'] = $forum_page['item_count'] = $forum_page['fld_count'] = 0;
 $forum_page['form_action'] = forum_link($forum_url['change_password'], $id);
 $forum_page['hidden_fields'] = array('form_sent' => '<input type="hidden" name="form_sent" value="1" />', 'csrf_token' => '<input type="hidden" name="csrf_token" value="' . generate_form_token($forum_page['form_action']) . '" />');
 // Setup breadcrumbs
 $forum_page['crumbs'] = array(array($forum_config['o_board_title'], forum_link($forum_url['index'])), array(sprintf($lang_profile['Users profile'], $user['username']), forum_link($forum_url['profile_about'], $id)), $forum_page['own_profile'] ? $lang_profile['Change your password'] : sprintf($lang_profile['Change user password'], forum_htmlencode($user['username'])));
     if (!isset($_POST['csrf_token']) && (!isset($_GET['csrf_token']) || $_GET['csrf_token'] !== generate_form_token('logout' . $forum_user['id']))) {
         csrf_confirm_form();
     }
     ($hook = get_hook('li_logout_selected')) ? eval($hook) : null;
     // Remove user from "users online" list.
     $query = array('DELETE' => 'online', 'WHERE' => 'user_id=' . $forum_user['id']);
     ($hook = get_hook('li_logout_qr_delete_online_user')) ? eval($hook) : null;
     $forum_db->query_build($query) or error(__FILE__, __LINE__);
     // Update last_visit (make sure there's something to update it with)
     if (isset($forum_user['logged'])) {
         $query = array('UPDATE' => 'users', 'SET' => 'last_visit=' . $forum_user['logged'], 'WHERE' => 'id=' . $forum_user['id']);
         ($hook = get_hook('li_logout_qr_update_last_visit')) ? eval($hook) : null;
         $forum_db->query_build($query) or error(__FILE__, __LINE__);
     }
     $expire = time() + 1209600;
     forum_setcookie($cookie_name, base64_encode('1|' . random_key(8, false, true) . '|' . $expire . '|' . random_key(8, false, true)), $expire);
     // Reset tracked topics
     set_tracked_topics(null);
     ($hook = get_hook('li_logout_pre_redirect')) ? eval($hook) : null;
     redirect(forum_link($forum_url['index']), $lang_login['Logout redirect']);
 } else {
     if (0) {
         if (!$forum_user['is_guest']) {
             header('Location: ' . forum_link($forum_url['index']));
         }
         ($hook = get_hook('li_forgot_pass_selected')) ? eval($hook) : null;
         if (isset($_POST['form_sent'])) {
             // User pressed the cancel button
             if (isset($_POST['cancel'])) {
                 redirect(forum_link($forum_url['index']), $lang_login['New password cancel redirect']);
             }
示例#18
0
if (!is_object($xoopsUser) && empty($admin_form_action)) {
	$required = !empty($xoopsModuleConfig["require_name"]);
	$forum_form->addElement(new XoopsFormText(_MD_NAMEMAIL, 'poster_name', 60, 255, ( !empty($isedit) && !empty($poster_name))?$poster_name:''), $required);
}

$icons_radio = new XoopsFormRadio(_MD_MESSAGEICON, 'icon', $icon);
$subject_icons = XoopsLists::getSubjectsList();
foreach ($subject_icons as $iconfile) {
	$icons_radio->addOption($iconfile, '<img src="'.XOOPS_URL.'/images/subject/'.$iconfile.'" alt="" />');
}
$forum_form->addElement($icons_radio);

$nohtml = ($forum_obj->getVar('allow_html'))?false:true;

if(!empty($editor)){
	forum_setcookie("editor",$editor);
}elseif(!$editor = forum_getcookie("editor")){
	//$editor = forum_getcookie("editor");
	if(is_object($xoopsUser)){
		$editor =@ $xoopsUser->getVar("editor"); // Need set through user profile
	}
	if(empty($editor)){
		$editor =@ $xoopsModuleConfig["editor_default"];
	}
}
$forum_form->addElement(new XoopsFormSelectEditor($forum_form, "editor", $editor, $nohtml));

$editor_configs = array();
$editor_configs["name"] ="message";
$editor_configs["value"] = $message;
$editor_configs["rows"] = empty($xoopsModuleConfig["editor_rows"])? 35 : $xoopsModuleConfig["editor_rows"];