Ejemplo n.º 1
0
function __apply($extra)
{
    $messages = array();
    if (!HTTPRequest::isParameter('numero', '/^\\d+$/')) {
        $messages['numero'] = 'El valor no es valido';
    }
    $letra = HTTPRequest::getParameter('letra', '');
    if ($letra && !preg_match('/^[A-Za-z]+$/', $letra)) {
        $messages['letra'] = 'El campo incluir puras letras';
    }
    if (count($messages) > 0) {
        return $messages;
    }
    echo "Ejecutar operacion en la BD<br>";
    return true;
}
 /** 
  * Returns HTML form bundle (for use in a form) for non-preferred labels attached to this row
  *
  * @param HTTPRequest $po_request The current request
  * @param string $ps_form_name
  * @param string $ps_placement_code
  * @param array $pa_bundle_settings
  * @param array $pa_options Array of options. Supported options are 
  *			noCache = If set to true then label cache is bypassed; default is true
  *
  * @return string Rendered HTML bundle
  */
 public function getNonPreferredLabelHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pa_bundle_settings = null, $pa_options = null)
 {
     global $g_ui_locale;
     if (!($t_label = $this->_DATAMODEL->getInstanceByTableName($this->getLabelTableName(), true))) {
         return null;
     }
     $vs_view_path = isset($pa_options['viewPath']) && $pa_options['viewPath'] ? $pa_options['viewPath'] : $po_request->getViewsDirectoryPath();
     $o_view = new View($po_request, "{$vs_view_path}/bundles/");
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     if (!isset($pa_options['dontCache'])) {
         $pa_options['dontCache'] = true;
     }
     if (!is_array($pa_bundle_settings)) {
         $pa_bundle_settings = array();
     }
     $o_view->setVar('id_prefix', $ps_form_name . '_NPref');
     $o_view->setVar('placement_code', $ps_placement_code);
     // pass placement code
     $o_view->setVar('labels', $va_labels = $this->getNonPreferredLabels(null, $pa_options['dontCache']));
     $o_view->setVar('t_subject', $this);
     $o_view->setVar('t_label', $t_label);
     $o_view->setVar('add_label', isset($pa_bundle_settings['add_label'][$g_ui_locale]) ? $pa_bundle_settings['add_label'][$g_ui_locale] : null);
     $o_view->setVar('graphicsPath', $pa_options['graphicsPath']);
     unset($pa_bundle_settings['label']);
     $o_view->setVar('settings', $pa_bundle_settings);
     $va_new_labels_to_force_due_to_error = array();
     $va_inital_values = array();
     if ($this->getPrimaryKey()) {
         // generate list of inital form values; the label bundle Javascript call will
         // use the template to generate the initial form
         if (sizeof($va_labels)) {
             foreach ($va_labels as $vn_item_id => $va_labels_by_locale) {
                 foreach ($va_labels_by_locale as $vn_locale_id => $va_label_list) {
                     foreach ($va_label_list as $va_label) {
                         $va_inital_values[$va_label['label_id']] = $va_label;
                     }
                 }
             }
         }
     } else {
         if ($this->numErrors()) {
             foreach ($_REQUEST as $vs_key => $vs_value) {
                 if (!preg_match('/' . $ps_placement_code . $ps_form_name . '_NPref' . 'locale_id_new_([\\d]+)/', $vs_key, $va_matches)) {
                     continue;
                 }
                 $vn_c = intval($va_matches[1]);
                 if ($vn_new_label_locale_id = $po_request->getParameter($ps_placement_code . $ps_form_name . '_NPref' . 'locale_id_new_' . $vn_c, pString)) {
                     if (is_array($va_label_values = $this->getLabelUIValuesFromRequest($po_request, $ps_placement_code . $ps_form_name, 'new_' . $vn_c, true))) {
                         $va_label_values['locale_id'] = $vn_new_label_locale_id;
                         $va_new_labels_to_force_due_to_error[] = $va_label_values;
                     }
                 }
             }
         }
     }
     if (is_array($this->opa_failed_nonpreferred_label_inserts) && sizeof($this->opa_failed_nonpreferred_label_inserts)) {
         $va_new_labels_to_force_due_to_error = $this->opa_failed_preferred_label_inserts;
     }
     $o_view->setVar('new_labels', $va_new_labels_to_force_due_to_error);
     $o_view->setVar('label_initial_values', $va_inital_values);
     $o_view->setVar('batch', (bool) (isset($pa_options['batch']) && $pa_options['batch']));
     return $o_view->render($this->getLabelTableName() . '_nonpreferred.php');
 }
Ejemplo n.º 3
0
    if ($i >= 50) {
        file_put_contents($log, "[" . date('Y-m-d H:i:s') . "] [{$lend}] [{$session}] Maximo de solicitudes permitidas para {$lend}. Ha sido denegada\n", FILE_APPEND);
        return null;
    }
    $token = md5($token . "_" . $i);
    file_put_contents("{$path_temp}token.{$session}", $lend . "\n" . $token . "\n");
    //    file_put_contents($log, "[" . date('Y-m-d H:i:s') . "] [{$lend}] [{$session}] creando token {$token}\n", FILE_APPEND);
    $getcwd = getcwd() . '/';
    echo <<<PPP
{$token}
{$getcwd}{$path_temp}request.{$session}

PPP;
    return;
}
$token = HTTPRequest::getParameter('token', null, '/^\\w+$/');
if (!file_exists("{$path_temp}token.{$session}")) {
    file_put_contents($log, "[" . date('Y-m-d H:i:s') . "] [{$lend}] [{$session}] Solicitud de {$lend}: no hay archivo de sesion\n", FILE_APPEND);
    return null;
}
$data = explode("\n", file_get_contents("{$path_temp}token.{$session}"));
if (!$token || $data[1] != $token || !file_exists("{$path_temp}request.{$session}")) {
    file_put_contents($log, "[" . date('Y-m-d H:i:s') . "] [{$lend}] [{$session}] Solicitud de {$lend}: {$token} no reconocido\n", FILE_APPEND);
    return null;
}
$hf = fopen("{$path_temp}request.{$session}", 'r');
$data = array();
$parameters = array();
$k = null;
while (!feof($hf) && ($line = fgets($hf))) {
    $aux = array();
Ejemplo n.º 4
0
<?php

include "../Session.php";
include "../HTTPRequest.php";
// $_GET, $_POST, $_COOKIE = $_REQUEST
/*

$_REQUEST['name']
preg_match('/^\w+$/', $_REQUEST['name']);
$name = stripslashes($_REQUEST['name']);
*/
var_dump(HTTPRequest::isParameter('one'));
$_GET['one'] = true;
$_GET['two'] = '2';
var_dump(HTTPRequest::isParameter(array('one', 'two')));
$_GET['one'] = '1';
var_dump(HTTPRequest::isParameter(array('one', 'two'), '/^\\d+$/'));
$_GET = array();
var_dump(HTTPRequest::isParameter(array('one', 'two'), null, 'GET'));
echo "============================================================== <br>\n";
var_dump(HTTPRequest::getParameter('one', '1', '/\\d+/'));
var_dump(HTTPRequest::getParameter(array('one', 'two'), '1', '/\\d+/'));
echo "============================================================== <br>\n";
var_dump(HTTPRequest::getContext('one'), $_REQUEST);
var_dump(HTTPRequest::setContext(array('two' => 2)), $_REQUEST);
echo "============================================================== <br>\n";