HEX
Server: Apache/2.4.25 (Debian)
System: Linux server17 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64
User: web37 (1062)
PHP: 7.4.30
Disabled: show_source, highlight_file, apache_child_terminate, apache_get_modules, apache_note, apache_setenv, virtual, dl, disk_total_space, posix_getpwnam, posix_getpwuid, posix_mkfifo, posix_mknod, posix_setpgid, posix_setsid, posix_setuid, posix_uname, proc_nice, openlog, syslog, pfsockopen
Upload Files
File: /var/www/web37/htdocs/fickanzeiger/controllers/KeywordController.php
<?php
/**
 * Arfooo
 * 
 * @package    Arfooo
 * @copyright  Copyright (c) Arfooo Annuaire (fr) and Arfooo Directory (en)
 *             by Guillaume Hocine (c) 2007 - 2010
 *             http://www.arfooo.com/ (fr) and http://www.arfooo.net/ (en)
 * @author     Guillaume Hocine & Adrian Galewski
 * @license    http://creativecommons.org/licenses/by/2.0/fr/ Creative Commons
 */


class KeywordController extends AppController
{
    /**
     * Show keywords starting with letter
     */
    function showAction($letter)
    {
        if (!Config::get('keywordsEnabled') || !preg_match("#^[A-Z0-9]$#", $letter)) {
            return $this->return404();
        }

        //set adPage for display
        Display::set("adPage", "letter$letter");

        $keywordGroups = array();

        //retrieve keywors which start with $letter
        $keywords = $this->keyword->getKeywordsWithPrefix($letter);
        $keywordIds = array();

        foreach ($keywords as $keyword) {
            $keywordIds[] = $keyword['keywordId'];
        }

        //Count validated sites which contain keyword
        $c = new Criteria();
        $c->add("keywordId", $keywordIds, "IN");
        $c->addGroup("keywordId");
        $c->addInnerJoin("sites", "sites.siteId", "keywordsofsites.siteId");
        $c->add("status", "validated");
        $sitesCountsForKeyword = $this->keywordsOfSite->getArray($c, "count(*)", "keywordId");

        //foreach keyword on this page check have many sites include it and push it to prefix group
        foreach ($keywords as $keyword) {
            //if some site have this keyword
            if (isset($sitesCountsForKeyword[$keyword['keywordId']])) {
                $keyword['count'] = $sitesCountsForKeyword[$keyword['keywordId']];
            } else {
                //if no set counter to default 0
                $keyword['count'] = 0;
            }

            //if group for this prefix doesn't exists so far
            if (!isset($keywordGroups[$keyword['prefix']]['keywords'])) {
                //create group for this prefix
                $keywordGroups[$keyword['prefix']]['keywords'] = array();
            }

            //add keyword to prefix group
            $keywordGroups[$keyword['prefix']]['keywords'][] = $keyword;
        }

        $this->set("letter", $letter);
        $this->set("keywordGroups", $keywordGroups);
    }
}