注意:未定义的索引:按钮样式



我正在运行一个PHP脚本,当我在VPS上托管文件但不在web-server上托管文件时会出现此错误。

这是错误:

注意:未定义的索引:按钮样式 C:\xampp\htdocs\steamauth\steamauth.php 在第 19 行

这是脚本(C:\xampp\htdocs\steamauth\steamauth.php)

<?php
 ob_start();
 session_start();
 require ('openid.php');
 function logoutbutton() {
echo "<form action="steamauth/logout.php" method="post"><input value="Logout" type="submit" /></form>"; //logout button
}
function steamlogin()
{
try {
require("steamauth/settings.php");
$openid = new LightOpenID($steamauth['domainname']);
$button['small'] = "small";
$button['large_no'] = "large_noborder";
$button['large'] = "large_border";
$button = $button[$steamauth['buttonstyle']];
if(!$openid->mode) {
    if(isset($_GET['login'])) {
        $openid->identity = 'http://steamcommunity.com/openid';
        header('Location: ' . $openid->authUrl());
    }
//echo "<form action="?login" method="post"> <input type="image" src="http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_".$button.".png"></form>";
}
 elseif($openid->mode == 'cancel') {
    echo 'User has canceled authentication!';
} else {
    if($openid->validate()) { 
            $id = $openid->identity;
            $ptn = "/^http://steamcommunity.com/openid/id/(7[0-9]{15,25}+)$/";
            preg_match($ptn, $id, $matches);
            $_SESSION['steamid'] = $matches[1]; 
            include_once("set.php");
            $query = mysql_query("SELECT * FROM users WHERE steamid='".$_SESSION['steamid']."'");
            if (mysql_num_rows($query) == 0) {
                mysql_query("INSERT INTO users (steamid) VALUES ('".$_SESSION['steamid']."')") or die("MySQL ERROR: ".mysql_error());
            }
            if (isset($steamauth['loginpage'])) {
                header('Location: '.$steamauth['loginpage']);
            }
    } else {
            echo "User is not logged in.n";
    }
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
}
?>

或(为了更好看的版本):http://pastebin.com/gEQT0SUW

这是蒸汽身份验证/设置的代码.php

<?php
 $steamauth['apikey'] = "CANT SAHRE IT. PRIVATE"; // Your Steam WebAPI-Key found at http://steamcommunity.com/dev/apikey
 $steamauth['domainname'] = "CANT SAHRE IT. PRIVATE"; // The main URL of your website displayed in the login page
 $steamauth['logoutpage'] = ""; // Page to redirect to after a successfull logout (from the directory the SteamAuth-folder is located in) - NO slash at the beginning!
 $steamauth['loginpage'] = "/"; // Page to redirect to after a successfull login (from the directory the SteamAuth-folder is located in) - NO slash at the beginning!
?>

在您的设置中。Php 文件没有可用的索引与 $steamauth['buttonstyle'] .

溶液:

您需要在设置中定义$steamauth['buttonstyle'].php将所需的值归档为:

$steamauth['apikey'] = "CANT SAHRE IT. PRIVATE";
$steamauth['domainname'] = "CANT SAHRE IT. PRIVATE"; 
$steamauth['logoutpage'] = "";
$steamauth['loginpage'] = "/";
$steamauth['buttonstyle'] = "value that you need"; // add this index

在按钮样式索引中设置此 URL 所需的值:

http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_".$button.".png

最新更新