🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: be.comp.programming
1 messages
1 total messages Started by Coppieters-Driessen Thu, 10 Oct 2002 16:43
php probleem
#7223
Author: Coppieters-Driessen
Date: Thu, 10 Oct 2002 16:43
154 lines
5416 bytes
Hoi,

wie kan mij helpen met onderstaand script "game_dispenser.php"?

Probleem:

1- functie "clean old files" werkt niet, krijgt volgende foutcode. Warning:
unlink() failed (Is a directory) in /home/www1host/public_html/mijn
link/cgi-bin/game_dispenser.php on line 76.
Warning: cannot add header information - headers already sent by (output
started at /home/www1host/public_html/mijn
link/cgi-bin/game_dispenser.php:76)in/home/www1host/public_html/yannick/cgi-
bin/game_dispenser.php on line 116



directory bestaat als volgt.

root/cgi-bin/game_dispenser.php
root/cgi-bin/sk_sessions/...txt files die het script aangemaakt heeft.

2- functie "prepare cookie" werkt ook niet. Script maakt geen cookie aan op
mijn pc. Mijn brouwser was tijdens controle niet afgesloten.

Kan iemand eventueel het script aanpassen?

Groetjes.

Het script.

# INSTRUCTIONS:
#
# The session id folder must be created manually before this script will
# function properly.
#
# Send this script a game location via GET or POST, such as:
#
#      game_url=http://www.foo.com/bar/game.html

# Where is your session id folder?  This folder will be located relative to
# this script.  It must match with the folder location specified in the
# ScoreKeeper script.
$session_id_folder = 'sk_sessions';

# Where are your games located?  This should be set as restrictive as
possible.
# If you are certain that all games located on your server are valid, you
may
# simply use 'http:\/\/www.foo.com'.  Notice that some of the
meta-characters,
# such as a forward slash, "/", require escaping with a back slash...like
this:
# "\/".
$game_validator = 'http:\/\/www.www1host.net';

#
############################################################################
####

# CLEAN OLD FILES
clean_old_files();

# VALIDATE GAME.
validate_game();

# CREATE ID.
create_id();

# SAVE ID VARIABLES.
save_id_variables();

# PREPARE COOKIE.
prepare_cookie();

# PRINT REDIRECT HEADER.
print_redirect_header();

# WHEW! FINISHED!
exit;

function clean_old_files() {
    global $session_id_folder;
    # gather up all of the session id filenames
    $dr = opendir($session_id_folder) or error("Invalid session id folder.
Failed at line " . __LINE__ . ".");
    $files = readdir($dr);
    closedir($dr);
    # change to session id folder
    chdir($session_id_folder);
    settype($files, "array");
    foreach ($files as $fcheck) {
        # look for files that are older than approximately 1 hr and delete
them
        if (time()-filemtime($fcheck) > 3600) {
            unlink($fcheck);
        }
    }
}

function validate_game() {
    global $HTTP_GET_VARS, $HTTP_POST_VARS;
    global $game_url, $game_validator;
    $game_url = ($HTTP_POST_VARS['game_url'] ? $HTTP_POST_VARS['game_url'] :
$HTTP_GET_VARS['game_url']);
    preg_match('/^' . $game_validator . '.*/', $game_url) or error("Game URL
could not be validated at line " .
__LINE__ . ".");
}

function create_id() {
    global $sk_id;
    # unique id is made up of 3 parts, separated by underscores:
    # 1) process id
    # 2) IP address
    # 3) number of non-leap seconds since January 1, 1970
    $remote_addr = getenv('REMOTE_ADDR');
    preg_replace('/\./', '/_/', $remote_addr);
    $sk_id = getmypid() . '_' . $remote_addr . '_' . time();
    # the ScoreKeeper script is written to accept only alphanumeric ids
}

function save_id_variables() {
    global $sk_id;
    $fh = fopen($sk_id, "w") or error("Session file could not be opened at
line " . __LINE__ . ".");
    # this will save some environmental variables to the session id file
    fwrite($fh, getenv('HTTP_USER_AGENT'));
    fwrite($fh, "\n");
    fwrite($fh, getenv('REMOTE_ADDR'));
    fclose($fh);
}

function prepare_cookie() {
    global $sk_id;
    # cookie values should be as restrictive as possible
    # this cookie will expire when the browser closes
    # path set as '/' makes the cookie available to all files on your site
    setcookie('SK_ID', $sk_id, 0, '/');
}

function print_redirect_header() {
    global $game_url;
    print '<html><head>';
    print '<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=' . $game_url . '">';
    print '</html></head>';
}

function error($ouch) {
    # something went wrong
    print $ouch;
    exit;
}

?>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads