2014-03-29 14 views
1

there is 500 internal server error when i searched pa我正在使用高級搜索插件。當我搜索「瑪麗亞」或其他任何其他工作正常,但當我搜索「PA」它給我500內部服務器錯誤。它與其他查詢工作正常。我試圖用其他的詞搜索它的工作。500 socialengine的高級搜索插件中的AJAX請求中的內部服務器錯誤

ini_set('max_execution_time', 3000);  
ini_set('display_errors', 0); 
ini_set('display_startup_errors', 0); 
ini_set('error_reporting', E_STRICT); 



// Create application, translate, view 
$application = Engine_Api::getInstance()->getApplication(); 
$application->getBootstrap()->bootstrap('translate'); 
$view = Zend_Registry::get('Zend_View'); 

// $view->layout()->staticBaseUrl = $_REQUEST['static_base_url']; 
// $view->layout()->staticBaseUrl = base64_decode($_REQUEST['static_base_url']); 
Zend_Controller_Front::getInstance()->setBaseUrl(
     base64_decode($_REQUEST['static_base_url'])); 

//$wView = ((preg_replace('/[^0-9]/', '', @$_REQUEST['pageGlobalSearch']) == 1) ? true : false); 
$wView=false; 
// TO DO HERE 
try { 

    $coresearchApi = Engine_Api::_()->getApi('search', 'core'); 
    $values = $_REQUEST; 

    $query = $values['search']; 
    $trimquery = trim($query); 
    if ($trimquery == null) 
     exit(); 



    $item_per_page = $values['maxre']; 
    // get types from selected modules in back-end 
    $searchModulesTable = new Ynadvsearch_Model_DbTable_Modules(); 
    $enabled_types = $searchModulesTable->getAllEnabledTypes(null, $wView); 
    $types = array(); 
    foreach ($enabled_types as $module_types) { 
     foreach ($module_types as $module_type) { 
      $types[] = $module_type; 
     } 
    } 

    $paginator = Engine_Api::_()->getApi('search', 'ynadvsearch')->getPaginator(
      $query, $types, null, null); 

    $paginator->setItemCountPerPage($item_per_page); 
    $data = array(); 

    if (count($paginator) == 0) { 
     $data[] = array(
       'key' => $query, 
       'label' => $view->translate('No results were found'), 
       'type' => 'no_result_found_link', 
       'url' => $view->url(
         array(


         ), 'ynadvsearch_search', true) . '?is_search=1&query=' . $query 
     ); 
    } else { 
     $data[] = array(
       'key' => $query, 
       'label' => 'Hidden choice', 
       'url' => $view->url(
         array(


         ), 'ynadvsearch_search', true) . '?is_search=1&query=' . $query, 
       'type' => 'hidden_link' 
     ); 
     if (count($paginator) < $item_per_page) { 

      $temp_data = array(); 
      foreach ($paginator as $item) { 
       if (! $item) { 
        continue; 
       } 
       $type = $item['type']; 

       $item = Engine_Api::_()->getItem($type, $item['id']); 

       if (! $item) { 
        continue; 
       } 
       if (! is_object($item)) { 
        continue; 
       } 
       if (! $item instanceof Core_Model_Item_Abstract) { 
        continue; 
       } 
       if (!$item->getIdentity()) { 
        continue; 
       } 
       if ($type == 'user') { 
        if ($item->verified != 1 || $item->enabled != 1 || 
          $item->approved != 1) { 
         continue; 
        } 
       } 
       if (! isset($temp_data[$type])) { 
        $temp_data[$type] = array(); 
       } 
       if ($type == 'activity_action') { 
        $label = $item->body; 
       } else { 
        $label = $item->getTitle(); 
       } 
       $photo_url = $view->itemPhoto($item, 'thumb.icon'); 
       $photo_url = preg_replace('/\/index.php/', '', $photo_url); 

       $temp_data[$type][] = array(
         'photo' => $photo_url, 
         'label' => $label, 
         'url' => $item->getHref(), 
         'type' => $type, 
         'type_label' => $view->translate(getLabelType($type)) 
       ); 
      } 

      foreach ($temp_data as $item_type) { 
       foreach ($item_type as $item) { 
        $data[] = $item; 
       } 
      } 
     } else { 
      $temp_data = array(); 

      foreach ($paginator as $item) { 
       if (! $item) { 
        continue; 
       } 
       $type = $item['type']; 

       $item = Engine_Api::_()->getItem($type, $item['id']); 
       if (! $item) { 
        continue; 
       } 
       if (! is_object($item)) { 
        continue; 
       } 
       if (! $item instanceof Core_Model_Item_Abstract) { 
        continue; 
       } 
       if (!$item->getIdentity()) { 
        continue; 
       } 
       if ($type == 'user') { 
        if ($item->verified != 1 || $item->enabled != 1 || 
          $item->approved != 1) { 
         continue; 
        } 
       } 
       if (! isset($temp_data[$type])) { 
        $temp_data[$type] = array(); 
       } 
       if ($type == 'activity_action') { 
        $label = $item->body; 
       } else { 
        $label = $item->getTitle(); 
       } 

       $photo_url = $view->itemPhoto($item, 'thumb.icon'); 
       $photo_url = preg_replace('/\/index.php/', '', $photo_url); 
       $temp_data[$type][] = array(
         'photo' => $photo_url, 
         'label' => $label, 
         'url' => $item->getHref(), 
         'type' => $type, 
         'type_label' => $view->translate(getLabelType($type)) 
       ); 
      } 

      foreach ($temp_data as $item_type) { 
       foreach ($item_type as $item) { 
        $data[] = $item; 
       } 
      } 

      // $itemnum = $item_per_page; 
      $itemnum = ($item_per_page > count($data)) ? count($data) : $item_per_page; 
      while (count($data) < $item_per_page) { 
       $itemnum ++; 
       $paginator->setItemCountPerPage($itemnum); 
       $paginator->setCurrentPageNumber(1); 
       $item = $paginator->getItem($itemnum); 
       if (! $item) { 
        break; 
       } 
       $type = $item['type']; 

       $item = Engine_Api::_()->getItem($type, $item['id']); 
       if (! $item) { 
        continue; 
       } 
       if (!$item->getIdentity()) { 
        continue; 
       } 
       if ($type == 'user') { 
        if ($item->verified != 1 || $item->enabled != 1 || 
          $item->approved != 1) { 
         continue; 
        } 
       } 
       if (! isset($temp_data[$type])) { 
        $temp_data[$type] = array(); 
       } 
       if ($type == 'activity_action') { 
        $label = $item->body; 
       } else { 
        $label = $item->getTitle(); 
       } 

       $photo_url = $view->itemPhoto($item, 'thumb.icon'); 
       $photo_url = preg_replace('/\/index.php/', '', $photo_url); 
       $data[] = array(
         'photo' => $photo_url, 
         'label' => $label, 
         'url' => $item->getHref(), 
         'type' => $type, 
         'type_label' => $view->translate(getLabelType($type)) 
       ); 
      } 
     } 
    } 
    $data[] = array(
      'key' => $query, 
      'label' => $view->translate('Search more results'), 
      'url' => $view->url(
        array(

        ), 'ynadvsearch_search', true) . '?is_search=1&query=' . $query, 
      'type' => 'see_more_link' 
    ); 

    echo Zend_Json::encode($data); 

} catch (Exception $e) { 
    throw $e; 
} 

function getLabelType ($type) 
{ 
    return strtoupper('ITEM_TYPE_' . $type); 
} 
+0

這個問題非常含糊。你能添加一個jsFiddle嗎?或一個活的鏈接,或者你的源代碼與這個問題有關... – Sergio

+0

我已經更新了我的問題,請再次檢查並幫助我。 – Asif

+0

你有鏈接到實時頁面嗎?你有任何客戶端代碼干擾搜索/ ajax查詢嗎? – Sergio

回答

0

對於SocialEngine上的500個內部問題,它涉及PHP錯誤。只需檢查php錯誤日誌,你會看到有關這個問題的更多細節。

希望得到這個幫助。

相關問題