Jump to content

Latest PsychoStats working in PHP 7.x


bobl61

Recommended Posts

I can't seem to get the install script to work for PsychoStats. Error message is:

"Installation Aborted! The most likely cause for this error is that you have not created a database and database user for PsychoStats and/or entered your database name, database username and database user password into the config.php file. You need to create a database and a database user, and give that user full permissions on that database. The other possible reason for this error is that your session either timed out or another installation session was started. If that was the case you must start over and try again. Make sure you start the installation from the beginning and do not use your back button to attemp to restart the installation. Make sure you do not open a second installation window or it will fail again."

I have the database setup with a new user with full privileges to the psychostats database. I have entered the information into the config.php file. 

I'm running the server and stats on same machine (Windows 11).
Xampp - Apache/2.4.46 (Win64) OpenSSL/1.1.1g PHP/7.4.16

Any ideas?

 

2023-04-17_153343.png

Link to comment
Share on other sites

  • 2 weeks later...

It appears that the installation script is not setting the cookie required to proceed. The script resides in common.php:

<?php
/**
 *  This file is part of PsychoStats.
 *
 *  Written by Jason Morriss
 *  Copyright 2008 Jason Morriss
 *
 *  PsychoStats is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  PsychoStats is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with PsychoStats.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  Version: $Id: common.php 565 2008-10-10 12:27:02Z lifo $
 */
if (!defined("PSYCHOSTATS_INSTALL_PAGE")) die("Unauthorized access to " . basename(__FILE__));

define("PS_INSTALL_VERSION", '3.2.8b');

define("PS_ROOTDIR", rtrim(dirname(__DIR__), '/\\'));
define("PS_INSTALLDIR", __DIR__);

// enable some sane error reporting (ignore notice errors) and turn off the magic. 
// we also want to to disable E_STRICT.
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); 
//set_magic_quotes_runtime(0);
/**/
@ini_set('display_errors', 'On');
@ini_set('log_errors', 'On');
/**/

// IIS does not have REQUEST_URI defined (apache specific).
// This URI is handy in certain pages so we create it if needed.
if (empty($_SERVER['REQUEST_URI'])) {
    $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
    if (!empty($_SERVER['QUERY_STRING'])) {
        $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
    }
}

// read in all of our required libraries for basic functionality!
require_once(PS_ROOTDIR . "/includes/functions.php");
require_once(PS_ROOTDIR . "/includes/class_DB.php");
require_once(PS_ROOTDIR . "/includes/class_PS.php");
require_once(PS_ROOTDIR . "/includes/class_CMS.php");
require_once(PS_ROOTDIR . "/includes/class_HTTP.php");
require_once(PS_ROOTDIR . "/includes/class_session.php");

// try to load the current config
$dbtype = 'mysql';
$dbhost = 'localhost';
$dbport = '';
$dbname = 'psychostats';
$dbuser = '';
$dbpass = '';
$dbtblprefix = 'ps_';
$site_url = '';
if (file_exists(PS_ROOTDIR . "/config.php") and file_exists(PS_ROOTDIR . "/install/go-dbinit.php")) {
    @include_once(PS_ROOTDIR . "/config.php");
} else {
    echo "You must install game support before you can install PsychoStats, please see INSTALL.md for details.";
    exit;
}

// Initialize our global variables for PsychoStats. 
// Lets be nice to the global Name Space.
$db     = null;
$cms        = null;             // global PsychoCMS object
$php_scnm = $_SERVER['SCRIPT_NAME'];        // this is used so much we make sure it's global
// Sanitize PHP_SELF and avoid XSS attacks.
// We use the constant in places we know we'll be outputting $PHP_SELF to the user
define("SAFE_PHP_SCNM", htmlentities($_SERVER['REQUEST_URI'], ENT_QUOTES, "UTF-8"));

// create database handle
$db = PsychoDB::create(array(
    'dbtype' => 'mysql',
    'delaystart' => true,
    'fatal'  => false,
));

// start the PS CMS object
$cms = new PsychoCMS(array(
    'dbhandle'  => &$db,
    'plugin_dir'    => PS_ROOTDIR . '/plugins',
    'site_url'  => $site_url
));

**// this session will not actually store a session in a database or file.
// it's mearly used in the install for cookie support.
$cms->session = new PsychoSession(array(
    'cms'           => $cms,
    'cookiename'        => 'ps_install_sess',
    'cookiesalt'        => '',
    'cookiecompress'    => true,
    'cookieencode'      => true,
    'cookielifeoptions'     => 0,   
    'dbhandle'      => $db,
    'delaystart'        => true,
));**

$cms->init(true); // quick init; no plugins, session or user

$cms->init_theme('default', array( 
    'theme_default' => 'default',
    'theme_opt' => 'install_theme',
    'in_db'     => false,
    'force_theme'   => true,
    'fetch_compile' => false,
    'compile_id'    => 'install',
    'compile_dir'   => null,
    'js_compress'   => false,
    'css_compress'  => false,
    'template_dir'  => __DIR__ . '/themes',
    'theme_url' => null,
));
$cms->theme->load_styles();
$cms->theme->assign(array(
    'SELF'          => SAFE_PHP_SCNM,
    'install_version'   => PS_INSTALL_VERSION
));

// ----------------------------------
function init_session_opts($delete = false) {
    global $cms;
    $opts = $cms->session->load_session_options();
    if ($delete || !$opts || !$opts['install']) {
        $cms->session->set_opts(array('install' => uniqid(rand(),true)), true);
        $cms->session->save_session_options();
        $opts = $cms->session->load_session_options();
    }
    return $opts;
}

// load DB conf from POST'ed form, or session variables if no form variable was found
function load_db_opts($conf = null) {
    global $cms;
    $list = array('dbhost','dbport','dbname','dbuser','dbpass','dbtblprefix');
    $opts = $cms->session->load_session_options();
    foreach ($list as $var) {
        if ($conf and is_array($conf) and array_key_exists($var, $conf)) {
            $GLOBALS[$var] = $conf[$var];
#           print "CONF: $var == '$conf[$var]'<br>";
        } else if (array_key_exists($var, $opts)) {
            $GLOBALS[$var] = $opts[$var];
#           print "OPTS: $var == '$opts[$var]'<br>";
        }
    }
}

function save_db_opts() {
    global $cms, $dbhost, $dbport, $dbname, $dbuser, $dbpass, $dbtblprefix;
    $opts = $cms->session->load_session_options();
    $opts['dbhost'] = $dbhost;
    $opts['dbport'] = $dbport;
    $opts['dbname'] = $dbname;
    $opts['dbuser'] = $dbuser;`your text`
    $opts['dbpass'] = $dbpass;
    $opts['dbtblprefix'] = $dbtblprefix;
    $cms->session->save_session_options($opts);
}

?>

I've searched how to set cookie in PHP 7, but can't find a resolution for my particular problem.

Link to comment
Share on other sites

It appears a missing cookie is the problem? You should be able to check this easily yourself by looking in the browser to see if the cookie is there.

But database information isn't something that should be in a cookie, so I wouldn't expect cookie problems to result in that error - more likely, they'd result in forgetting you were logged in or what step of an installation wizard you were on.

Link to comment
Share on other sites

Database information really shouldn't be stored in a cookie...

Keep that developer console open and try going through the installation. Do you see the cookie ever show up? Are there errors in the Console that might suggest problems trying to set a cookie?

Link to comment
Share on other sites

With Firefox browser I get this error:

Cookie “ps_install_sess_opts” does not have a proper “SameSite” attribute value. Soon, cookies without the “SameSite” attribute or with an invalid value will be treated as “Lax”. This means that the cookie will no longer be sent in third-party contexts. If your application depends on this cookie being available in such contexts, please add the “SameSite=None“ attribute to it. To know more about the “SameSite“ attribute, read https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/SameSite index.php


Cookie “ps_install_sess_opts” has been rejected because a non-HTTPS cookie can’t be set as “secure”

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.