注意:未定义的索引:buttonstyle in

时间:2016-02-13 04:08:02

标签: php html

我正在运行PHP脚本,当我在VPS上托管文件但在web-server上托管文件时,会显示此错误。

这是错误:

  

注意:未定义的索引:buttonstyle in   第19行的C:\ xampp \ htdocs \ steamauth \ steamauth.php

这是脚本(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

以下是steamauth / settings.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!
?>

1 个答案:

答案 0 :(得分:2)

在您的setting.Php文件中,SELECT transAgg.ClientID, transAgg.Currency, transAgg.OrganizationName, transAgg.SaleGrandTotal, recovLogAgg.SumOfAmtReceived, (transAgg.SaleGrandTotal - recovLogAgg.SumOfAmtReceived) as SaleBalanceRemaining, purchAgg.PurchaseGrandTotal, purchLogAgg.SumOfAmtPaid, (purchAgg.PurchaseGrandTotal - purchLogAgg.SumOfAmtPaid) as PurchaseBalanceRemaining, ((transAgg.SaleGrandTotal - recovLogAgg.SumOfAmtReceived) - (purchAgg.PurchaseGrandTotal - purchLogAgg.SumOfAmtPaid)) As [Total] FROM (SELECT a.ClientID, f.CurrencyID, f.Currency, a.OrganizationName, COALESCE(sum(b.GrandTotal),0) as SaleGrandTotal FROM na_clients as a INNER JOIN na_currency as f LEFT JOIN na_transaction as b ON a.ClientID = b.ClientID AND b.CurrencyID = f.CurrencyID AND b.IsActive = 1 GROUP BY a.ClientID, a.OrganizationName, f.CurrencyID, f.Currency ORDER BY a.OrganizationName) As transAgg INNER JOIN (SELECT a.ClientID, f.CurrencyID, f.Currency, a.OrganizationName, COALESCE(sum(d.GrandTotal), 0) as PurchaseGrandTotal FROM na_clients as a INNER JOIN na_currency as f LEFT JOIN na_purchase as d ON a.ClientID = d.ClientID AND d.CurrencyID = f.CurrencyID AND d.IsActive = 1 GROUP BY a.ClientID, a.OrganizationName, f.CurrencyID, f.Currency ORDER BY a.OrganizationName) As purchAgg ON transAgg.ClientID = purchAgg.ClientID AND transAgg.CurrencyID = purchAgg.CurrencyID INNER JOIN (SELECT g.TID, COALESCE(sum(g.AmountReceived),0) As SumOfAmtReceived FROM na_recoverylogs as g GROUP BY g.TID) As recovlogAgg ON transAgg.TID = recovlogAgg.TID INNER JOIN (SELECT e.PID, COALESCE(sum(e.AmountPaid),0) As SumOfAmtPaid FROM na_purchaselogs as e GROUP BY e.PID) As purchlogAgg ON purchAgg.PID = purchlogAgg.PID 没有可用的索引。

<强>解决方案:

您需要在setting.php文件中将$steamauth['buttonstyle']定义为所需的值:

$steamauth['buttonstyle']

设置此URL所需的buttonstyle索引中的值:

$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