2014-03-14 3 views
0

클래스를 호출 할 때 오류가 발생합니다.PHP 클래스를 호출하는 중 오류가 발생했습니다.

사이트 구성 파일에 클래스를 포함 시켰습니다.

include($GLOBALS["webpath"] . "/classes/LM_com.php"); 

내가 전화 할 때 찾을 수없는 오류가 발생합니다. 이 오류가 LM_com.php 클래스의

Fatal error: Class 'LM_com' not found in /home/{sitename}/public_html/pages/HotLoadSearchResults.php on line 35 

내용 받았다

$loads = LM_com::GetLocationSearchCriteria($sql, $urlappend, "l"); 

라인 35

<?php 
if (!defined("LM_NS_CLASSES_INCLUDED")) 
{ 
    define("LM_NS_CLASSES_INCLUDED", true); 

    define("HIDE_ORIGIN_CITY",  (1 << 1)); 
    define("HIDE_ORIGIN_ZIP",  (1 << 2)); 
    define("HIDE_DESTINATION_CITY", (1 << 3)); 
    define("HIDE_DESTINATION_ZIP", (1 << 4)); 
    define("HIDE_DESTINATION",  (1 << 5)); 
    define("ARCHIVE_POST",   (1 << 6)); 

    $GLOBALS["StatusMessages"] = array(
     "Company Deleted.",   // 0 
     "Company Activated.", 
     "Load Posted.",    // 2 
     "Load Updated.", 
     "Load Deleted.",   // 4 
     "Truck Posted.", 
     "Truck Updated.",   // 6 
     "Truck Deleted.", 
     "User Deactivated.",  // 8 
     "User Activated.", 
     "Passwords don't match.", // 10 
     "Password Changed.", 
     "User Deleted.",   // 12 
     "Error Activating User.", 
     "Error Deactivating User.", // 14 
     "Error Deleting User.", 
     "News Posted.",    // 16 
     "Error Posting News.", 
     "News Post Deleted.",  // 18 
     "Error Deleting News Post.", 
     "User Profile Updated.", // 20 
     "Error Updating User Profile.", 
     "Company Profile Updated.", // 22 
     "Error Updating Company Profile.", 
     "User Moved.",    // 24 
     "Error Moving User.", 
     "Error Adding User.",  // 26 
     "User Added.", 
     "Company Added.",   // 28 
     "Error Adding Company.", 
     "Email Sent.",    // 30 
     "No Emails Sent.", 
     "Cannot Add Blacklisted Email Address.", // 32 
     "Bid Placed.", 
     "Bid Not Placed."   // 34 
    ); 

    class UserOwnedObject 
    { 
     var $UserID = -1; 
     // does this session's user own this object? 
     function IsUserOwner() 
     { 
      if ($this->UserID == -1) 
       return false; 
      if (!isset($_SESSION["user"]) || !$_SESSION["user"]->IsLoggedIn()) 
       return false; 
      //if ($_SESSION["user"]->CheckPrivs("admin", "canDelete")) 
      // return true; 
      if ($this->UserID == $_SESSION["user"]->UserID) 
       return true; 
      return false; 
     } 
    } 

    function hex2asc($myin) 
    { 
     for ($i = 0; $i < strlen($myin)/2; $i++) 
     { 
      $myout .= chr(base_convert(substr($myin, $i*2, 2), 16, 10)); 
     } 
     return $myout; 
    } 

    // get the administrative email address for the site 
    // search order: config db, site-conf setting, Administrator user email address 
    function get_admin_email() 
    { 
     $conn = &$GLOBALS["dbSettings"]->GetConnection(); 
     $toaddr = ""; 
     // try getting admin email from config table first 
     $sql = "SELECT ConfigValue FROM config WHERE ConfigName = 'admin_email'"; 
     $conf = &$conn->Execute($sql); 
     if ($conf->RecordCount() > 0) 
      $toaddr = $conf->fields[0]; 
     else if (!empty($GLOBALS["site_AdminEmail"])) // try falling back on site-conf setting 
     { 
      $toaddr = $GLOBALS["site_AdminEmail"]; 
     } 
     else // last resort, look for a user named Administrator 
     { 
      // toaddr email address should come from username = 'Administrator' 
      $sql = "SELECT Email FROM users WHERE UserName = 'Administrator'"; 
      $rs = &$conn->Execute($sql); 
      if ($rs === false) 
       die("internal error:" . $conn->ErrorMsg() . " SQL: " . $sql); 
      $toaddr = $rs->fields[0]; 
     } 
     return $toaddr; 
    } 

    // this is a big chunk of search results code that's used for both loads & trucks 







    function GetEquipmentSearchCriteria(&$sql, &$urlappend, $prefix) 
    { 
     // if no equipment search options given, use 0 to mean any equipment matches 
     if (!isset($GLOBALS["EquipmentID"]) || empty($GLOBALS["EquipmentID"])) 
      $GLOBALS["EquipmentID"] = array(); 
     // make the equipmentid list an array if it isn't one 
     if (!is_array($GLOBALS["EquipmentID"])) 
      $GLOBALS["EquipmentID"] = explode(",", $GLOBALS["EquipmentID"]); 

     $conn = &$GLOBALS["dbSettings"]->GetConnection(); 

     // if there are any equipment search options, prepare the sql append 
     if (sizeof($GLOBALS["EquipmentID"]) > 0) 
     { 
      $gsql = "SELECT EquipmentID, SearchGroup FROM equipment WHERE EquipmentID IN (" . implode(",", $GLOBALS["EquipmentID"]) . ")"; 
      $groups = $conn->Execute($gsql); 
      $search_ids = ""; 
      while (!$groups->EOF) 
      { 
       if (!empty($search_ids)) 
        $search_ids .= ","; 
       $search_ids .= $groups->fields[1]; 
       $groups->MoveNext(); 
      } 
      if (!empty($search_ids)) 
       $sql .= " AND " . $prefix . ".EquipmentID IN (" . $search_ids . ")"; 
     } 

     // do the same thing for lengths now 

     // if no length search options given, use 0 to mean any length matches 
     if (!isset($GLOBALS["Length"]) || empty($GLOBALS["Length"])) 
      $GLOBALS["Length"] = array(); 
     // make the length list an array if it isn't one 
     if (!is_array($GLOBALS["Length"])) 
      $GLOBALS["Length"] = explode(",", $GLOBALS["Length"]); 
     // if there are any length search options, prepare the sql append 
     if (sizeof($GLOBALS["Length"]) > 0) 
     { 
      $gsql = "SELECT LengthID, SearchGroup FROM length WHERE LengthID IN (" . implode(",", $GLOBALS["Length"]) . ")"; 
      $len_groups = $conn->Execute($gsql); 
      if ($len_groups === false) 
       die($conn->ErrorMsg() . " SQL: " . $gsql); 
      $group_ids = ""; 
      while (!$len_groups->EOF) 
      { 
       if (!empty($group_ids)) 
        $group_ids .= ","; 
       $group_ids .= $len_groups->fields[1]; 
       $len_groups->MoveNext(); 
      } 
      if (!empty($group_ids)) 
       $sql .= " AND " . $prefix . ".LengthID IN (" . $group_ids . ")"; 
     } 

     $urlappend .= "&EquipmentID=" . implode(",", $GLOBALS["EquipmentID"]) . 
         "&Length=" . implode(",", $GLOBALS["Length"]); 
    } 







    function GetLocationSearchCriteria(&$sql, &$urlappend, $prefix) 
    { 
     $origin_id = Location::GetLocationID($GLOBALS["OriginState"], $GLOBALS["OriginCity"], $GLOBALS["OriginZip"]); 
     $destination_id = Location::GetLocationID($GLOBALS["DestinationState"], $GLOBALS["DestinationCity"], $GLOBALS["DestinationZip"]); 

     if (!is_array($origin_id)) 
     { 
      $o = $origin_id; 
      $origin_id = array(); 
      $origin_id[0] = $o; 
     } 
     if (!is_array($destination_id)) 
     { 
      $d = $destination_id; 
      $destination_id = array(); 
      $destination_id[0] = $d; 
     } 

     if (!empty($GLOBALS["OriginRadius"])) 
     { 
      $origin = new Location($origin_id[0]); 
      $origin_id = $origin->GetRadiusLocations($GLOBALS["OriginRadius"]); 
      $urlappend .= "&OriginRadius=" . $GLOBALS["OriginRadius"]; 
     } 
     if (!empty($GLOBALS["DestinationRadius"])) 
     { 
      $destination = new Location($destination_id[0]); 
      $destination_id = $destination->GetRadiusLocations($GLOBALS["DestinationRadius"]); 
      $urlappend .= "&DestinationRadius=" . $GLOBALS["DestinationRadius"]; 
     } 

     // remember search params 
     if (!empty($GLOBALS["OriginState"])) 
      $urlappend .= "&OriginState=" . $GLOBALS["OriginState"]; 
     if (!empty($GLOBALS["OriginCity"])) 
      $urlappend .= "&OriginCity=" . $GLOBALS["OriginCity"]; 
     if (!empty($GLOBALS["OriginZip"])) 
      $urlappend .= "&OriginZip=" . $GLOBALS["OriginZip"]; 

     if (!empty($GLOBALS["DestinationState"])) 
      $urlappend .= "&DestinationState=" . $GLOBALS["DestinationState"]; 
     if (!empty($GLOBALS["DestinationCity"])) 
      $urlappend .= "&DestinationCity=" . $GLOBALS["DestinationCity"]; 
     if (!empty($GLOBALS["DestinationZip"])) 
      $urlappend .= "&DestinationZip=" . $GLOBALS["DestinationZip"]; 

     // build query 
     if ($origin_id[0] != -1) 
      $sql .= " AND " . $prefix . ".OriginLocationID IN (" . implode(",", $origin_id) . ") "; 

     if ($destination_id[0] != -1) 
      $sql .= " AND " . $prefix . ".DestinationLocationID IN (" . implode(",", $destination_id) . ") "; 
    } 








     function GetLocationSearchCriteria1(&$sql, &$urlappend, $prefix) 
    { 
     $origin_id = Location::GetMultiLocationID($GLOBALS["OriginState"]); 
     $destination_id = Location::GetMultiLocationID($GLOBALS["DestinationState"]); 

     if (!is_array($origin_id)) 
     { 
      $o = $origin_id; 
      $origin_id = array(); 
      $origin_id[0] = $o; 
     } 
     if (!is_array($destination_id)) 
     { 
      $d = $destination_id; 
      $destination_id = array(); 
      $destination_id[0] = $d; 
     } 

     if (!empty($GLOBALS["OriginRadius"])) 
     { 
      $origin = new Location($origin_id[0]); 
      $origin_id = $origin->GetRadiusLocations($GLOBALS["OriginRadius"]); 
      $urlappend .= "&OriginRadius=" . $GLOBALS["OriginRadius"]; 
     } 
     if (!empty($GLOBALS["DestinationRadius"])) 
     { 
      $destination = new Location($destination_id[0]); 
      $destination_id = $destination->GetRadiusLocations($GLOBALS["DestinationRadius"]); 
      $urlappend .= "&DestinationRadius=" . $GLOBALS["DestinationRadius"]; 
     } 

     // remember search params 
     if (!empty($GLOBALS["OriginState"])) 
      $urlappend .= "&OriginState=" . $GLOBALS["OriginState"]; 

     if (!empty($GLOBALS["DestinationState"])) 
      $urlappend .= "&DestinationState=" . $GLOBALS["DestinationState"]; 

     // build query 
     if ($origin_id[0] != -1) 
      $sql .= " AND " . $prefix . ".OriginLocationID IN (" . implode(",", $origin_id) . ") "; 

     if ($destination_id[0] != -1) 
      $sql .= " AND " . $prefix . ".DestinationLocationID IN (" . implode(",", $destination_id) . ") "; 
    } 











    function GetMultiLocationSearchCriteria(&$sql, &$urlappend, $prefix) 
    { 
     $state_vals = array(); 
     $city_vals = array(); 
     $zip_vals = array(); 
     if (!empty($GLOBALS["OriginState"])) 
     { 
      $GLOBALS["OriginState"] = explode(",", $GLOBALS["OriginState"]); 
      $s = "SELECT DISTINCT LocationID FROM locations WHERE StateInitials IN ('" . implode("','", $GLOBALS["OriginState"]) . "')"; 
      $conn = &$GLOBALS["dbSettings"]->GetConnection(); 
      $rs = &$conn->Execute($s); 
      if ($rs === false) die("panic:" . $conn->ErrorMsg() . " SQL: " . $s); 
      $vals = array(); 
      while (!$rs->EOF) 
      { 
       array_push($vals, $rs->fields[0]); 
       $rs->MoveNext(); 
      } 
      $state_vals = $vals; 
     } 
     if (!empty($GLOBALS["OriginCity"])) 
     { 
      $GLOBALS["OriginCity"] = explode(",", $GLOBALS["OriginCity"]); 
      $s = "SELECT DISTINCT LocationID FROM locations WHERE City IN ('" . implode("','", $GLOBALS["OriginCity"]) . "')"; 
      $conn = &$GLOBALS["dbSettings"]->GetConnection(); 
      $rs = &$conn->Execute($s); 
      if ($rs === false) die("panic:" . $conn->ErrorMsg() . " SQL: " . $s); 
      $vals = array(); 
      while (!$rs->EOF) 
      { 
       array_push($vals, $rs->fields[0]); 
       $rs->MoveNext(); 
      } 
      $city_vals = $vals; 
     } 
     if (!empty($GLOBALS["OriginZip"])) 
     { 
      $GLOBALS["OriginZip"] = explode(",", $GLOBALS["OriginZip"]); 
      $s = "SELECT DISTINCT LocationID FROM locations WHERE ZipCode IN ('" . implode("','", $GLOBALS["OriginZip"]) . "')"; 
      $conn = &$GLOBALS["dbSettings"]->GetConnection(); 
      $rs = &$conn->Execute($s); 
      if ($rs === false) die("panic:" . $conn->ErrorMsg() . " SQL: " . $s); 
      $vals = array(); 
      while (!$rs->EOF) 
      { 
       array_push($vals, $rs->fields[0]); 
       $rs->MoveNext(); 
      } 
      $zip_vals = $vals; 
     } 

     // remember search params 
     if (!empty($state_vals)) 
      $urlappend .= "&OriginState=" . implode(",", $GLOBALS["OriginState"]); 
     if (!empty($city_vals)) 
      $urlappend .= "&OriginCity=" . implode(",", $GLOBALS["OriginCity"]); 
     if (!empty($zip_vals)) 
      $urlappend .= "&OriginZip=" . implode(",", $GLOBALS["OriginZip"]); 
     // build query 
     $vals = array_unique(array_merge($state_vals, $city_vals, $zip_vals)); 
     if (!empty($vals)) 
      $sql .= " AND " . $prefix . ".OriginLocationID IN (" . implode(",", $vals) . ") "; 

     if (!empty($GLOBALS["DestinationState"])) 
     { 
      $GLOBALS["DestinationState"] = explode(",", $GLOBALS["DestinationState"]); 
      $s = "SELECT DISTINCT LocationID FROM locations WHERE StateInitials IN ('" . implode("','", $GLOBALS["DestinationState"]) . "')"; 
      $conn = &$GLOBALS["dbSettings"]->GetConnection(); 
      $rs = &$conn->Execute($s); 
      if ($rs === false) die("panic:" . $conn->ErrorMsg() . " SQL: " . $s); 
      $vals = array(); 
      while (!$rs->EOF) 
      { 
       array_push($vals, $rs->fields[0]); 
       $rs->MoveNext(); 
      } 
      if (!empty($vals)) 
      { 
       $sql .= " AND "; 
       $sql .= $prefix . ".DestinationLocationID IN (" . implode(",", $vals) . ") "; 
      } 
      $urlappend .= "&DestinationState=" . implode(",", $GLOBALS["DestinationState"]); 
     } 
     if (!empty($GLOBALS["DestinationCity"])) 
     { 
      $GLOBALS["DestinationCity"] = explode(",", $GLOBALS["DestinationCity"]); 
      $s = "SELECT DISTINCT LocationID FROM locations WHERE City IN ('" . implode("','", $GLOBALS["DestinationCity"]) . "')"; 
      $conn = &$GLOBALS["dbSettings"]->GetConnection(); 
      $rs = &$conn->Execute($s); 
      if ($rs === false) die("panic:" . $conn->ErrorMsg() . " SQL: " . $s); 
      $vals = array(); 
      while (!$rs->EOF) 
      { 
       array_push($vals, $rs->fields[0]); 
       $rs->MoveNext(); 
      } 
      if (!empty($vals)) 
       $sql .= " AND " . $prefix . ".DestinationLocationID IN (" . implode(",", $vals) . ") "; 
      $urlappend .= "&DestinationCity=" . implode(",", $GLOBALS["DestinationCity"]); 
     } 
     if (!empty($GLOBALS["DestinationZip"])) 
     { 
      $GLOBALS["DestinationZip"] = explode(",", $GLOBALS["DestinationZip"]); 
      $s = "SELECT DISTINCT LocationID FROM locations WHERE ZipCode IN ('" . implode("','", $GLOBALS["DestinationZip"]) . "')"; 
      $conn = &$GLOBALS["dbSettings"]->GetConnection(); 
      $rs = &$conn->Execute($s); 
      if ($rs === false) die("panic:" . $conn->ErrorMsg() . " SQL: " . $s); 
      $vals = array(); 
      while (!$rs->EOF) 
      { 
       array_push($vals, $rs->fields[0]); 
       $rs->MoveNext(); 
      } 
      if (!empty($vals)) 
       $sql .= " AND " . $prefix . ".DestinationLocationID IN (" . implode(",", $vals) . ") "; 
      $urlappend .= "&DestinationZip=" . implode(",", $GLOBALS["DestinationZip"]); 
     } 
    } 
} 
?> 
+0

'포함'을'require'로 변경하십시오 - 성공적으로 포함 되었습니까? – tchow002

+1

"LM_com.php"파일의 내용을 표시 할 수 있습니까? 또한'$ GLOBALS [ 'webpath']'의 값을 반향 시켜서 그것이 예상 한 것과 같은지 확인하십시오. – JMTyler

+0

거기에 파일의 내용이 있습니다 ... 그리고 내가 필요로 포함 변경 작업을 했어 webpath 잘 같은 페이지에서 다른 클래스를 호출 괜찮아요 ... –

답변

1

당신이 클래스가 코드에서 LM_com 이름 정의하지 않는 오프 먼저 게시했습니다. 적절한 클래스는 아래에 게시 된 것과 같은 클래스 구조에 포함되어 있습니다.

class lm_com 
{ 
    public function hex2asc($myin) 
    { 
     // ... 
    } 

    public function get_admin_email() 
    { 
     // ... 
    } 

    public function GetEquipmentSearchCriteria(&$sql, &$urlappend, $prefix) 
    { 
     // ... 
    } 

    public function GetLocationSearchCriteria(&$sql, &$urlappend, $prefix) 
    { 
     // ... 
    } 

    public function GetLocationSearchCriteria1(&$sql, &$urlappend, $prefix) 
    { 
     // ... 
    } 

    public function GetMultiLocationSearchCriteria(&$sql, &$urlappend, $prefix) 
    { 
     // ... 
    } 
} 

두 번째로 class 콜론 className :: methodName이있는 구문을 사용하여 클래스의 메소드를 호출하려고 시도했습니다.

이 구문은 클래스 구조 외부에서 사용될 때 정적 클래스 메서드를 호출 할 때만 작동합니다. 정적 클래스 메서드는 해당 메서드를 호출하기 전에 클래스 인스턴스를 만들 필요가 없습니다.

그때 당신이 있습니다 설명한대로 클래스와 메소드를 정의한 후 다음 형식은 클래스

public static function GetLocationSearchCriteria(&$sql, &$urlappend, $prefix) 
{ 
    // ... 
} 

의 인스턴스를 생성하지 않고 호출 할 수있는 공공 정적 메서드를 정의하는 데 사용됩니다 LM_com::GetLocationSearchCriteria($sql, $urlappend, "l");