<commit_before><?php
/**
 * @author <NAME> <<EMAIL>>
 *
 */

namespace angelrove\membrillo2;

use angelrove\membrillo2\Login\LoginCtrl;
use angelrove\membrillo2\WApp\Session;


class AppCmsAjax extends Application
{
    //-----------------------------------------------------------------
    public function __construct($document_root)
    {
        parent::__construct($document_root);

        //----------------------------------------------------
        /* Globals */
        global $CONFIG_SECCIONES,
               $seccCtrl,
               $objectsStatus;

        //----------------------------------------------------//
        LoginCtrl::init_ajax();

        $CONFIG_SECCIONES = Session::get('CONFIG_SECCIONES');
        $seccCtrl         = Session::get('seccCtrl'); //$seccCtrl->initPage();
        $objectsStatus    = Session::get('objectsStatus');

        //----------------------------------------------------
        /* System services */
        $this->system_services();

        //----------------------------------------------------//
        /* User Service */
        $secc_dir = '';
        if (isset($_REQUEST['secc']) && $_REQUEST['secc']) {
            $secc_dir = DOCUMENT_ROOT . '/app/' . $_REQUEST['secc'];
        } else {
            $secc_dir = $CONFIG_SECCIONES->getFolder($seccCtrl->secc);
        }

        $service_path = $secc_dir . '/ajax-' . $_REQUEST['service'] . '.inc';

        // Load service ----
        try {
            if ((file_exists($service_path))) {
                include $service_path;
            } else {
                throw new \Exception("membrillo2 error: Service not found [$service_path]");
            }
        } catch (\Exception $e) {
            throw $e;
        }

    }
    //-----------------------------------------------------------------
    private function system_services()
    {
        if (!isset($_REQUEST['sys_service'])) {
            return true;
        }

        switch ($_REQUEST['sys_service']) {
            case 'Messages_get':
                Messages::get();
                break;
            default:
                throw new \Exception('membrillo2 error: service not found');<commit_msg>AppCmsAjax: adaptar para ejecutar scripts<commit_after><?php
/**
 * @author <NAME> <<EMAIL>>
 *
 */

namespace angelrove\membrillo2;

use angelrove\membrillo2\Login\LoginCtrl;
use angelrove\membrillo2\WApp\Session;


class AppCmsAjax extends Application
{
    //-----------------------------------------------------------------
    public function __construct($document_root)
    {
        parent::__construct($document_root);

        //----------------------------------------------------
        /* Globals */
        global $CONFIG_SECCIONES,
               $seccCtrl,
               $objectsStatus;

        //----------------------------------------------------//
        LoginCtrl::init_ajax();

        $CONFIG_SECCIONES = Session::get('CONFIG_SECCIONES');
        $seccCtrl         = Session::get('seccCtrl'); //$seccCtrl->initPage();
        $objectsStatus    = Session::get('objectsStatus');

        //----------------------------------------------------
        /* System services */
        $this->system_services();

        //----------------------------------------------------//
        /* User Service */
        $secc_dir = '';
        if (isset($_REQUEST['secc']) && $_REQUEST['secc']) {
            $secc_dir = DOCUMENT_ROOT . '/app/' . $_REQUEST['secc'];
        } else {
            $secc_dir = $CONFIG_SECCIONES->getFolder($seccCtrl->secc);
        }

        $service_path        = $secc_dir . '/ajax-' . $_REQUEST['service'] . '.inc';
        $service_path_script = $secc_dir . '/script-' . $_REQUEST['service'] . '.php';

        // Load service ----
        try {
            if (file_exists($service_path)) {
                include $service_path;
            }
            elseif (file_exists($service_path_script)) {
                include $service_path_script;
            }
            else {
                throw new \Exception("membrillo2 error: Service not found [$service_path]");
            }
        } catch (\Exception $e) {
            throw $e;
        }

    }
    //-----------------------------------------------------------------
    private function system_services()
    {
        if (!isset($_REQUEST['sys_service'])) {
            return true;
        }

        switch ($_REQUEST['sys_service']) {
            case 'Messages_get':
                Messages::get();
                break;
            default:
                throw new \Exception('membrillo2 error: service not found');
{'fraction_non_alphanumeric': 0.2685245193346295, 'fraction_numerical': 0.002160293799956794, 'mean_word_length': 1.1726888784608165, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6229967', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1133, 'n_words': 200}