Esempio n. 1
0
function forum_antispam_update($cost)
{
    $score = forum_antispam_credits();
    $new_score = $score - $cost;
    $new_info['login']['last_forum_antispam_modification'] = time();
    $new_info['login']['last_forum_antispam_score'] = $new_score;
    login_save_user_data($_SESSION['login']['id'], $new_info);
    session_merge($new_info);
}
Esempio n. 2
0
<?php

require '../include/core/common.php';
if ($_SESSION['login']['id'] > 0) {
    $new_info['login']['lastaction'] = 0;
    login_save_user_data($_SESSION['login']['id'], $new_info);
}
if (isset($_COOKIE[session_name()])) {
    setcookie(session_name(), '', time() - 42000, '/');
}
session_destroy();
jscript_go_back();
Esempio n. 3
0
        return $return;
    }
    return true;
}
if (!login_checklogin()) {
    echo 'Nu gick något fel, du loggades inte in...';
    trace('register_error', 'register.php acsessed by not logged on user...');
} else {
    if (isset($_POST['submit_button'])) {
        $check = regform_check($_POST);
        if ($check === true) {
            unset($data);
            $data['userinfo']['gender'] = $_POST['gender'];
            $data['userinfo']['zip_code'] = $_POST['zip_code'];
            $data['userinfo']['birthday'] = $_POST['birth_year'] . '-' . $_POST['birth_month'] . '-' . $_POST['birth_day'];
            login_save_user_data($_SESSION['login']['id'], $data);
            session_merge($data);
            /*$alert = 'Tackar! Nu skickar vi dig till en introduktionssida som berättar mer om Hamsterpaj,\\n';
            		$alert .= 'vad man gör här och hur sidan fungerar, du måste inte läsa den om du inte vill.';
            		jscript_alert($alert);
            		jscript_location('/hamsterpaj/introduction.php');*/
            jscript_alert('Eftersom Lef inte gjort klart välkommen-sidan ännu så kan vi inte skicka dig till den. Hursomhelst så är du välkommen till hamsterpaj, och vi skickar dig nu till startsidan för träffa.\\n\\nDet skulle dessutom vara kul för folk att veta vem du är, klicka på Inställningar i menyn så kan du ladda upp en bild på dig själv eller göra din egna presentation.\\n\\nÅter igen; välkommen!');
            jscript_location('/traffa/');
        } else {
            regform_fail();
            regform_settings($_POST, $check);
        }
    } else {
        regform_header();
        regform_settings();
    }
Esempio n. 4
0
function forum_favourite_category_remove($handle)
{
    /* Copy the old data to a new variabel, then empty the session array and copy the old data, skipping the category to remove */
    $old = $_SESSION['preferences']['forum_favourite_categories'];
    $_SESSION['preferences']['forum_favourite_categories'] = array();
    foreach ($old as $category) {
        if ($handle != $category) {
            $_SESSION['preferences']['forum_favourite_categories'][] = $category;
        }
    }
    $db_save['preferences']['forum_favourite_categories'] = mysql_real_escape_string(serialize($_SESSION['preferences']['forum_favourite_categories']));
    login_save_user_data($_SESSION['login']['id'], $db_save);
}
Esempio n. 5
0
function posts_create($post, $options)
{
    /*
    		Required info: 
    			content
    			discussion_id
    			author
    		
    		Optional info:
    			timestamp
    */
    /*
    	$post['content'] = str_replace('(</p><p>)+', '</p><p>', $post['content']);
    	$post['content'] = str_replace('(<br />)+', '<br />', $post['content']);
    */
    if (forum_read_only_get($post['author'])) {
        echo 'Error: Användaren avstängd från forumet' . "\n";
        return false;
    }
    $post['content'] = trim($post['content']);
    $content = mysql_real_escape_string($post['content']);
    $quality_rank = text_quality_rank($post['content']);
    $spelling_grammar = text_quality_rank($post['content']);
    $post['timestamp'] = isset($post['timestamp']) ? $post['timestamp'] : time();
    $query = 'INSERT INTO posts (author, length, content, discussion_id, quality_rank, spelling_grammar, timestamp, no_smilies)';
    $query .= ' VALUES("' . $post['author'] . '", "' . strlen($post['content']) . '", "' . $post['content'] . '", "' . $post['discussion_id'];
    $query .= '", "' . $quality_rank . '", "' . $spelling_grammar . '", "' . $post['timestamp'] . '", "';
    $query .= (isset($post['no_smilies']) ? '1' : '0') . '")';
    mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__));
    $post_id = mysql_insert_id();
    /* Increase the post counter */
    $query = 'UPDATE discussions SET posts = posts + 1, last_post = "' . $post_id . '" WHERE id = "' . $post['discussion_id'] . '" LIMIT 1';
    mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__));
    if (isset($options['gb_recipient'])) {
        /* Update the "unread entries" in the remote users session */
        $query = 'SELECT session_id FROM login WHERE id = "' . $options['gb_recipient'] . '" LIMIT 1';
        $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__));
        if (mysql_num_rows($result) == 1) {
            $data = mysql_fetch_assoc($result);
            if (strlen($data['session_id']) > 1) {
                $remote_session = session_load($data['session_id']);
                $remote_session['notices']['unread_gb_entries'] += 1;
                session_save($sessid_data['session_id'], $remote_session);
            }
        }
        /* If a private entry has been sent, set the appropriate flag */
        if ($options['private_gb'] == true) {
            $query = 'INSERT INTO flags (object_id, object_type, flag) VALUES("' . $post_id . '", "post", "private_gb")';
            mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__));
        }
    }
    //Parse to find answer tags
    foreach (preg_split('/\\n/', $content) as $line) {
        // find tags like: [svar:AmarsoLove=3245]
        // 					eller: [svar:Henrik]
        if (preg_match('/\\[svar:(\\w+)(=\\d+)?\\]/', $line, $matches)) {
            //Fetch user_id
            if (strtolower($matches[1]) != 'borttagen') {
                $query = 'SELECT id FROM login WHERE username = "******"';
                $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__));
                if (mysql_num_rows($result) == 1) {
                    $data = mysql_fetch_assoc($result);
                    $receiver_id = $data['id'];
                    //Insert response notice
                    $query = 'INSERT INTO notices (user_id, post_id, type) VALUES ("' . $receiver_id . '", "' . $post_id . '", "response")';
                    mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__));
                }
            }
        }
    }
    //Send notices to all users listed in $options['notices']
    if (isset($options['notices'])) {
        foreach ($options['notices'] as $receiver) {
            if (strtolower($matches[1]) != 'borttagen') {
                //Fetch user_id
                $query = 'SELECT id FROM login WHERE username = "******"';
                $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__));
                if (mysql_num_rows($result) == 1) {
                    $data = mysql_fetch_assoc($result);
                    $receiver_id = $data['id'];
                    //Insert response notice
                    $query = 'INSERT INTO notices (user_id, post_id, type) VALUES ("' . $receiver_id . '", "' . $post_id . '", "notice")';
                    log_to_file('forum', LOGLEVEL_DEBUG, __FILE__, __LINE__, 'notiser', $query);
                    mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__));
                }
            }
        }
    }
    //Update users quality rank
    //todo! This will require some thinking and adjustments in the future
    if (login_checklogin()) {
        $user_quality_rank = ($_SESSION['userinfo']['forum_quality_rank'] * 9 + $quality_rank) / 10;
        unset($data);
        $data['userinfo']['forum_quality_rank'] = $user_quality_rank;
        login_save_user_data($_SESSION['login']['id'], $data);
        session_merge($data);
        //Update discussion quality rank
        $query = 'SELECT quality_rank FROM posts WHERE discussion_id ="' . $post['discussion_id'] . '" ORDER BY id DESC LIMIT 30';
        $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__));
        while ($data = mysql_fetch_assoc($result)) {
            $quality_ranks[] = $data['quality_rank'];
        }
        sort($quality_ranks);
        $discussion_quality_rank = $quality_ranks[floor(count($quality_ranks) / 2)];
        $query = 'UPDATE discussions SET quality_rank="' . $discussion_quality_rank . '" WHERE id = "' . $post['discussion_id'] . '"';
        mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__));
    }
    //Update discussion popularity
    $slot = floor(date('G') / 3);
    $slot_pre = $slot - 1;
    $date_pre = date('Y-m-d');
    if ($slot_pre < 0) {
        $slot_pre = 7;
        $date_pre = date('Y-m-d', strtotime('yesterday'));
    }
    $query_update = 'UPDATE discussion_statistics SET posts = posts + 1 WHERE discussion_id = "' . $post['discussion_id'] . '" AND date = "' . date('Y-m-d') . '" AND slot = "' . $slot . '"';
    $query_posts_pre = 'SELECT posts FROM discussion_statistics WHERE discussion_id = "' . $post['discussion_id'] . '" AND date = "' . $date_pre . '" AND slot = "' . $slot_pre . '" LIMIT 1';
    //	log_to_file('forum', LOGLEVEL_DEBUG, __FILE__, __LINE__, $post['discussion_id'] . ' ' . $slot . ' ' . $slot_pre, $query_posts_pre);
    // Update the popularity for the tags that the discussion has been tagged with.
    $tags = tag_get_by_item('discussion', $post['discussion_id']);
    foreach ($tags as $tag) {
        $query = 'UPDATE tags SET popularity = IF(popularity IS NULL, 0.05, popularity + 0.05) WHERE id = "' . $tag['tag_id'] . '" LIMIT 1';
        mysql_query($query) or die(report_sql_error($query));
    }
    $result = mysql_query($query_posts_pre);
    if ($data = mysql_fetch_assoc($result)) {
        //		log_to_file('forum', LOGLEVEL_DEBUG, __FILE__, __LINE__, $data['posts'], $query_posts_pre);
        $posts_pre = $data['posts'];
    }
    $query_insert = 'INSERT INTO discussion_statistics (discussion_id, date, slot, posts, posts_pre) VALUES ("' . $post['discussion_id'] . '", "' . date('Y-m-d') . '", "' . $slot . '", "1",' . ' "' . $posts_pre . '")';
    //	log_to_file('forum', LOGLEVEL_DEBUG, __FILE__, __LINE__, 'insert', $query_insert);
    if (mysql_query($query_insert)) {
        log_to_file('forum', LOGLEVEL_DEBUG, __FILE__, __LINE__, 'Vi körde insert!', $query_insert);
    } elseif (mysql_query($query_update)) {
        log_to_file('forum', LOGLEVEL_DEBUG, __FILE__, __LINE__, 'Vi körde update!', $query_update);
    } else {
        log_to_file('forum', LOGLEVEL_DEBUG, __FILE__, __LINE__, $query_update, $query_insert);
        exit;
    }
    $_SESSION['posts']['latest'][] = array('timestamp' => $time, 'hash' => md5($post['content']));
    return $post_id;
}
Esempio n. 6
0
    		$file_handle = fopen(PATHS_NCLUDE . 'message_bar_current.txt', 'w');
    		fwrite($file_handle, $message_bar);
    		fclose($file_handle);*/
    jscript_alert('Din bild är nu sparad och lagd på förhandsgranskning\\nFör att din nya bild ska visas kan du behöva trycka på F5. Om din gamla bild fortsätter visas är detta helt normalt, det kan ta ett par dagar innan din dator "glömt av" den gamla bilden och hämtat den nya!');
    if (isset($_POST['registerproccess'])) {
        jscript_location('/register.php?nextstep=3&bild=1');
    } else {
        jscript_location('/installningar/generalsettings.php');
    }
}
// Ta bort
if ($_GET['action'] == 'delete') {
    $img_full_filename = $img_path_full . $_SESSION['userid'] . '.jpg';
    $img_thumb_filename = $img_path_thumb . $_SESSION['userid'] . '.jpg';
    $newdata['userinfo']['image'] = 0;
    login_save_user_data($_SESSION['userid'], $newdata);
    $_SESSION['userinfo']['image'] = 0;
    if (is_file($img_full_filename)) {
        unlink($img_full_filename);
    }
    if (is_file($img_thumb_filename)) {
        unlink($img_thumb_filename);
    }
    jscript_alert('Din bild är nu borttagen!');
    jscript_location($hp_url . 'avatarsettings.php');
}
ui_top($ui_options);
/*
- - - - - - - - - - - - - - 
SID-KODEN
- - - - - - - - - - - - - -