示例#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);
}
示例#2
0
    }
    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();
    }
}
示例#3
0
        case 'password':
            if (hamsterpaj_password(utf8_decode($_POST['password_old'])) != $_SESSION['login']['password']) {
                jscript_alert('Det där går inte, du måste skriva in ditt nuvarande lösenord, annars funkar inte skiten. Seså, gör om gör rätt!');
                jscript_go_back();
                exit;
            }
            if ($_POST['password_new'] != $_POST['password_verify']) {
                jscript_alert('"Nytt lösenord" och "Upprepa nytt lösenord" måste ju vara samma, annars funkar det ju inte :(');
                jscript_go_back();
                exit;
            }
            $newdata['login']['password'] = hamsterpaj_password(utf8_decode($_POST['password_new']));
            break;
    }
    login_save_user_data($_SESSION['login']['id'], $newdata);
    session_merge($newdata);
    jscript_alert('Ändrat, fixat och donat :)');
    jscript_location($_SERVER['PHP_SELF']);
}
if ($_POST['action'] == 'profile_theme') {
    $query = 'UPDATE userinfo SET profile_theme = "' . $_POST['theme'] . '" WHERE userid = "' . $_SESSION['login']['id'] . '" LIMIT 1';
    mysql_query($query) or report_sql_error($query);
    $_SESSION['userinfo']['profile_theme'] = $_POST['theme'];
}
/* Frivillig information */
$out .= '<a name="optional_info"></a>';
$out .= rounded_corners_tabs_top($void, true);
$out .= '<h2 style="margin-top: 0px;">Frivillig information</h2>' . "\n";
$out .= '<form action="' . $_SERVER['PHP_SELF'] . '?action=perform_changes&type=optional_info" method="post" name="optional_info">';
$out .= '<strong>Är du flicka eller pojke?</strong><br />' . "\n";
$out .= '<input type="radio" name="gender" value="m" ';
示例#4
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;
}