Exemplo n.º 1
0
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use ApacheSolrForTypo3\Solr\Api;
use TYPO3\CMS\Core\Utility\HttpUtility;
$api = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('api');
$apiKey = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('apiKey'));
if (!Api::isValidApiKey($apiKey)) {
    header(HttpUtility::HTTP_STATUS_403);
    header('Content-Type: application/json; charset=utf-8');
    echo json_encode(array('errorMessage' => 'Invalid API key'));
} else {
    switch ($api) {
        case 'siteHash':
            include 'SiteHash.php';
            break;
        default:
            header(HttpUtility::HTTP_STATUS_400);
            header('Content-Type: application/json; charset=utf-8');
            echo json_encode(array('errorMessage' => 'You must provide an available API method, e.g. siteHash.'));
            break;
    }
}
 /**
  * Index action, shows an overview of the state of the Solr index
  *
  * @return void
  */
 public function indexAction()
 {
     $this->checkConnections();
     $this->view->assign('site', $this->request->getArgument('site'));
     $this->view->assign('apiKey', Api::getApiKey());
 }