2015-05-26 34 views
0

將PHP網站更改爲新服務器後,這些錯誤不斷出現。如何搜索定義的類或變量的位置

月1日 - 由

Notice: Undefined variable: es in /home/musthand/public_html/external/site/header.php on line 2 

<?php 
if(!is_object($es)) 
{ 
    require_once('includes/EliteScript.php'); 
    $es = new EliteScript(); 
    $sMemberId = $es->getMemberId(); 
} 

// Get the base URL 
$sBaseUrl = $es->getConfig('baseUrl'); 
$sImageUrl = $es->getConfig('imageUrl'); 
$sMemberId = $es->getMemberId(); 
$sUsername = $es->getMemberUsername($sMemberId); 
$sIP  = $_SERVER['REMOTE_ADDR']; 

// Vars we want to pass to the system 
$aJSVars = array(
     'member_url' => $es->getConfig('memberUrl'), 
     'base_url'  => $es->getCOnfig('baseUrl'), 
     'image_url'  => $es->getConfig('imageUrl'), 
     'date'   => date("F d, Y H:i:s", time()), 
); 

$ba = new BannerAd(); 
?> 

第二

Fatal error: Class 'FOrum' not found in /home/musthand/public_html/interface/forum.php on line 33 

    <?php 
global $es; 
global $ui; 
global $member_id; 
global $base_url; 
global $member_url; 
global $image_url; 
global $admin_url; 
require_once("includes/EliteScript.php"); 
$es = new EliteScript(); 
$ui = new UserInterface(); 
$es->RequireMember(); 
$member_id = $es->GetMemberId(); 
$base_url = $es->GetConfig("baseUrl"); 
$member_url = $es->GetConfig("memberUrl"); 
$image_url = $es->GetConfig("imageUrl"); 
$es->DisplayHeader("Forum", "member.php"); 
$_REQUEST["do"]; 
display_main(); 
$es->DisplayFooter(); 


function display_main() 
{ 
    global $es; 
    global $ui; 
    global $member_id; 
    global $base_url; 
    global $member_url; 
    global $image_url; 
    global $admin_url; 
    $cur_sign = $es->GetCurrencySign(); 
    $f = new FOrum(); 
    echo "<script>\n</script>\n\n<div class=\"bigHeader\">Forum</div>\n"; 
    echo $ui->GenerateMessageBox("msg", 0, 5); 
    echo $ui->GenerateErrorBox("err", 0, 5); 
    echo "\n"; 
    echo $ui->DisplayToolTip("Forum", "Below you can participate in the company forum."); 
    echo "<br>\n\n\n"; 
    $q = "SELECT * FROM forumSections ORDER BY id"; 
    $r = mysql_query($q); 
    while($l = mysql_fetch_array($r)) 
    { 
     $l_sid = $l["id"]; 
     $l_sec_name = htmlentitiesi($l["name"]); 
     echo "<div class=\"header\">"; 
     echo $l_sec_name; 
     echo "</div>\n<table cellspacing=\"1\" cellpadding=\"0\" border=\"0\" width=\"100%\" class=\"dataTbl\">\n<tr class=\"tblHeader\">\n<td>Forum</td>\n<td width=\"50\" align=\"center\">Topics</td>\n<td width=\"50\" align=\"center\">Replies</td>\n<td width=\"150\" align=\"right\">Last Post Info</td>\n</tr>\n"; 
     $html = NULL; 
     $qb = "SELECT * FROM forums WHERE sectionId='" . $l_sid . "' ORDER BY id"; 
     $rb = mysql_query($qb); 
     while($lb = mysql_fetch_array($rb)) 
     { 
      $l_fid = $lb["id"]; 
      $l_name = htmlentitiesi($lb["name"]); 
      $l_desc = htmlentitiesi($lb["description"]); 
      $l_topics = $f->GetForumTopicCount($l_fid); 
      $l_replies = $f->GetForumReplyCount($l_fid); 
      $html .= "<tr class=\"tblRowA\">\n\t\t\t<td style=\"padding: 5px 0px 5px 5px;\">\n\t\t\t<a href=\"\"><b>" . $l_name . "</b></a>\n\t\t\t<div style=\"padding-top: 5px;\">\n\t\t\t" . $l_desc . "\n\t\t\t</div>\n\t\t\t\n\t\t\t</td>\n\t\t\t<td align=\"center\">" . $l_topics . "</td>\n\t\t\t<td align=\"center\">" . $l_replies . "</td>\n\t\t\t<td align=\"right\">" . $l_lastpost . "</td>\n\t\t\t</tr>"; 
     } 
     echo $html; 
     echo "</table>\n\n"; 
    } 
    echo "\n\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n<br>\n\n\n\n\n\n<div class=\"header\">News & Updates</div>\n<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n"; 
    $html = NULL; 
    $q = "SELECT * FROM news ORDER BY added DESC,id DESC LIMIT 5"; 
    $r = mysql_query($q); 
    while($l = mysql_fetch_array($r)) 
    { 
     $l_id = $l["id"]; 
     $l_title = htmlentitiesi($l["title"]); 
     $l_date = date("M jS", strtotime($l["added"])); 
     $html .= "<tr class=\"sepLine\"><td width=\"20\"><img src=\"" . $image_url . "/note.png\" width=\"16\" height=\"16\"></td><td><a href=\"" . $member_url . "/news.php?do=view&id=" . $l_id . "\">" . $l_title . "</a> <i style=\"color:gray;\">(" . $l_date . ")</i></td></tr>\n"; 
    } 
    if(!$html) 
    { 
     $html = "<tr class=\"sepLine\"><td style=\"color: gray;\">Currently no news and updates...</td></tr>"; 
    } 

    echo $html; 
    echo "</table>\n<br>\n\n<div class=\"header\">Account Summary</div>\n\n<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n<tr class=\"sepLine\">\n<td width=\"20\"><img src=\""; 
    echo $image_url; 
    echo "/user.png\" width=\"16\" height=\"16\"></td>\n<td width=\"175\"><b>Member Info:</b></td>\n<td>"; 
    echo $username; 
    echo " (#"; 
    echo $member_id; 
    echo ") <i>(<a href=\"mailto:"; 
    echo $email; 
    echo "\">"; 
    echo $email; 
    echo "</a>)</i></td>\n<td align=\"right\"><a href=\""; 
    echo $member_url; 
    echo "/preferences.php\">[Preferences]</a></td>\n</tr>\n</table>\n\n<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n<tr><td class=\"toolTip\">\nYou must "; 
    echo $req_text; 
    echo " before participating.</td></tr>\n</table>\n\n\n\n\n<div class=\"header\">Current Active "; 
    echo $token_label; 
    echo "s</div>\n\n<table cellspacing=\"1\" cellpadding=\"0\" border=\"0\" width=\"100%\" class=\"dataTbl\">\n<tr class=\"tblHeader\">\n<td width=\"50\">ID</td>\n<td>Type</td>\n<td width=\"40\">Units</td>\n<td width=\"80\">Amount</td>\n<td width=\"150\">Earned So Far</td>\n<td width=\"80\">Created</td>\n</tr>\n\n"; 
    $tok_types = $es->GetConfig("tokenTypes"); 
    $html = NULL; 
    $tblClass = "tblRowA"; 
    $q = "SELECT * FROM tokens WHERE memberId='" . $member_id . "' AND status = 'ACTIVE' ORDER BY created DESC,id DESC"; 
    $r = mysql_query($q); 
    while($l = mysql_fetch_array($r)) 
    { 
     $l_id = $l["id"]; 
     $l_type = $l["type"]; 
     $tok_arr = $tok_types[$l_type]; 
     $l_name = htmlentitiesi($tok_arr["name"]); 
     $l_amt = $l["amount"]; 
     $l_esf = $l["earnedSoFar"]; 
     $l_exp_type = $l["expireType"]; 
     $l_exp_val = $l["expiresOnValue"]; 
     $l_created = $l["createdDate"]; 
     $l_lastroi = $l["lastRoiDate"]; 
     $l_incycle = $l["inCycle"]; 
     $l_status = $l["status"]; 
     if($l_status == "ACTIVE") 
     { 
      $lb_status = "<span style=\"color: darkgreen;\">Active</span>"; 
     } 
     else 
     { 
      if($l_status == "EXPIRED") 
      { 
       $lb_status = "<span style=\"color: red;\">Expired</span> as of " . date("M jS, y", strtotime($l["expiresDate"])); 
      } 

     } 

     if($l_created == $l_lastroi && $l_incycle <= 1) 
     { 
      $l_lastearn_text = "Never"; 
     } 
     else 
     { 
      $l_lastearn_text = date("M jS, y", strtotime($l_lastroi)); 
     } 

     $l_units = sprintf("%d", $l["units"]); 
     $l_earned_per = sprintf("%.2f", $l_esf/$l_amt * 100); 
     $earned_per_style = "color: gray;"; 
     if(100 < $l_earned_per) 
     { 
      $earned_per_style = "color: darkgreen;"; 
     } 

     $l_created_date = date("M jS, y", $l["created"]); 
     if($l_exp_type == "value") 
     { 
      $l_exp_text = sprintf("%.2f", $l_exp_val) . "%"; 
      $l_exp_text .= " <i>(" . $cur_sign . sprintf("%.2f", $l_amt * $l_exp_val/100) . ")</i>"; 
     } 
     else 
     { 
      if($l_exp_type == "date") 
      { 
       $l_exp_text = date("M jS, y", $l["expires"]); 
      } 
      else 
      { 
       if($l_exp_type == "never") 
       { 
        $l_exp_text = "No Set Expiry"; 
       } 

      } 

     } 

     $lb_amt = number_format($l_amt, 2); 
     $lb_esf = number_format($l_esf, 2); 
     $html .= "\n\t\t<tr class=\"" . $tblClass . "\">\n\t\t<td>#" . $l_id . "</td>\n\t\t<td><b>" . $l_name . "</b></td>\n\t\t\n\t\t<td>" . $l_units . "</td>\n\t\t<td>" . $cur_sign . $lb_amt . "</td>\n\t\t<td>" . $cur_sign . $lb_esf . " <i style=\"" . $earned_per_style . "\">(" . $l_earned_per . "%)</i></td>\n\t\t<td>" . $l_created_date . "</td>\n\t\t</tr>\n\t\t<tr class=\"" . $tblClass . "\">\n\t\t<td colspan=\"6\" style=\"padding-left: 20px;\">\n\t\t\n\t\t<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n\t\t<tr><td width=\"170\">\n\t\t<u>Last Earn Date:</u> " . $l_lastearn_text . "\n\t\t</td><td width=\"190\">\n\t\t<u>Expires:</u> " . $l_exp_text . "\n\t\t</td><td>\n\t\t<u>Status:</u> " . $lb_status . "\n\t\t</td></tr>\n\t\t</table>\n\t\t\n\t\t</td>\n\t\t</tr>"; 
     $tblClass = $tblClass == "tblRowA" ? "tblRowB" : "tblRowA"; 
    } 
    if(!$html) 
    { 
     $html .= "<tr class=\"" . $tblClass . "\"><td colspan=\"7\"><span style=\"color: gray;\">Currently no active " . $token_label . "s...</span></td></tr>"; 
    } 

    echo $html; 
    echo "</table>\n\n<br><br>\n\n"; 
} 


?> 

他們曾經工作的老服務器上的精「shaddy」解決了,我不知道該怎麼對新的這些錯誤的了。

它們被定義在某個文件的某處,有800多個文件,很難在每一個文件中搜索。

有沒有什麼辦法可以讓服務器看起來像這些類或變量被定義的實際文件?

+0

這些意見是兩回事。 第一個可能是使用PHP版本,它處理異常的方式,或者錯誤可能一直存在,並且您的舊服務器上只會出現錯誤報告。 第二個錯誤指​​示類缺失。它可能位於不同的名稱空間下,位於不同的位置,或者自動加載器可能存在錯誤 – NickOS

+0

然後,我該如何修復它? – Steve

+0

第一個問題修復爲「shaddy's」的回覆 – Steve

回答

0

您的代碼從未正常工作。寫得不好。您在舊服務器中沒有看到錯誤的原因是您的錯誤報告較低或整個錯誤報告已關閉。當你正在開發一些東西時,你應該總是在打開錯誤報告的情況下開發,這樣你才能看到你的錯誤。

的第一個問題是在這裏

if(!is_object($es)) { 

您可以直接檢查$es爲對象,但這是錯誤的,因爲這種說法是在文件的頂部,$es將贈品不確定的,除非你將其導入從全球範圍內,像這樣:

global $es; 

if(!is_object($es)) { 

你的第二個錯誤是因爲你錯誤地引用了Forum類:

$f = new FOrum(); 

我想這應該是:

$f = new Forum(); 
+0

我的開發人員開發了腳本bro。全球美元;修正了第一個問題。但第二個沒有改成$ f = new Forum(); – Steve

+0

@Steve你應該搜索那麼什麼是論壇類的正確名稱,這是因爲具有這種名稱的類不存在。我無法猜測它遠程抱歉。 – shaddy

+0

這可以,兄弟,謝謝你的第一次修復。 – Steve

相關問題