socialengine的高级搜索插件中ajax请求中的500内部服务器错误

时间:2014-03-29 21:40:41

标签: php ajax xmlhttprequest mootools socialengine

there is 500 internal server error when i searched pa我正在使用高级搜索插件。当我搜索“玛利亚”或其他任何其工作正常,但当我搜索“pa”它给我500内部服务器错误。它与其他查询一起工作正常。我试着用其他词来搜索它的工作。

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);
}

1 个答案:

答案 0 :(得分:0)

对于SocialEngine上的500内部问题,它与PHP错误有关。只需检查php错误日志,您将看到有关此问题的更多详细信息。

希望这有帮助。