Пример #1
0
 function str2json($str)
 {
     $str = str_replace(',', ',', $str);
     $str = str_replace('【', '[', $str);
     $str = str_replace('】', ']', $str);
     $str = str_replace(':', ':', $str);
     $arr = StringToArray($str);
     $str = '';
     foreach ($arr as $v) {
         if ($v == '[' || $v == ']' || $v == ',') {
             if ($str) {
                 $block = explode(':', trim($str));
                 $blockArr['a'] = $block[0];
                 $blockArr['t'] = isset($block[1]) ? $block[1] : $block[0];
                 $arr2[] = $blockArr;
             }
             $v == ',' || ($arr2[] = $v);
             $str = '';
         } else {
             $str .= $v;
         }
     }
     if ($arr2[0] == '[') {
         unset($arr2[0]);
         array_pop($arr2);
     }
     // dump ( $arr2 );
     // 通过栈的原理把一维数组转成多维数据
     $wareroom = array();
     foreach ($arr2 as $k => $vo) {
         if ($vo == ']') {
             // 逆向出栈
             $count = count($wareroom) - 1;
             for ($i = $count; $i >= 0; $i--) {
                 if ($wareroom[$i] == '[') {
                     $parent = $i - 1;
                     array_pop($wareroom);
                     break;
                 } else {
                     $d[] = array_pop($wareroom);
                 }
             }
             krsort($d);
             $wareroom[$parent]['d'] = $d;
             unset($d);
         } else {
             // 入栈
             array_push($wareroom, $vo);
         }
     }
     // dump ( $wareroom );
     return $wareroom;
 }
Пример #2
0
function getCascadeTitle($ids, $extra)
{
    $idArr = explode(',', $ids);
    $idArr = array_filter($idArr);
    if (empty($idArr)) {
        return '';
    }
    parse_str($extra, $arr);
    if ($arr['type'] == 'db') {
        $table = $arr['table'];
        unset($arr['type'], $arr['table']);
        $arr['token'] = get_token();
        $arr['id'] = array('in', $idArr);
        $list = M($table)->where($arr)->field('title')->select();
        $titleArr = getSubByKey($list, 'title');
    } else {
        $str = str_replace(',', ',', $extra);
        $str = str_replace('【', '[', $str);
        $str = str_replace('】', ']', $str);
        $str = str_replace(':', ':', $str);
        $arr = StringToArray($str);
        $str = '';
        foreach ($arr as $v) {
            if ($v == '[' || $v == ']' || $v == ',') {
                if ($str) {
                    $block = explode(':', trim($str));
                    if (in_array($block[0], $idArr)) {
                        $titleArr[] = isset($block[1]) ? $block[1] : $block[0];
                    }
                }
                $str = '';
            } else {
                $str .= $v;
            }
        }
    }
    return implode(' > ', $titleArr);
}
Пример #3
0
<?php

include 'co_Bdd.php';
header('Content-Type: application/json');
//phpinfo();
/*
	---- VALUE ----
	.Get name
	.Get password
*/
try {
    if (checkArgument()) {
        $user = checkUser($_GET['name'], $_GET['password'], $bdd);
        $disp = array("Status" => "Success", "ID" => $user['id'], "Name" => $_GET['name'], "Password" => $_GET['password'], "Matieres" => StringToArray($user['matiere']), "Roles" => StringToArray($user['roles']));
        echo json_encode($disp, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
    }
} catch (Exception $e) {
    $disp = array("Status" => "Error", "Message" => $e->getMessage(), "Code" => $e->getCode());
    echo json_encode($disp, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
}
function checkUser($name, $password, $bdd)
{
    $requete = $bdd->prepare('SELECT * FROM user WHERE name = ? AND password = ?');
    $requete->execute(array($name, $password));
    $resultat = $requete->fetch();
    if (!$resultat) {
        throw new Exception('LogInvalid', 01);
    }
    return $resultat;
}
function checkArgument()
Пример #4
0
function getGridDatosESOP($pagina = -1, $codactividad = 0, $codigo = 0, $descripcion = '', $inFiltroRiesgos = '')
{
    validarSessionServer(isset($_SESSION["isCliente"]));
    if ($pagina == -1) {
        $pagina = 1;
    }
    if (isset($_REQUEST["pagina"])) {
        $pagina = $_REQUEST["pagina"];
    }
    $ob = '';
    if (isset($_REQUEST["ob"])) {
        $ob = $_REQUEST["ob"];
    }
    $showProcessMsg = false;
    $result = '';
    if ($inFiltroRiesgos != '') {
        $inFiltroRiesgos = StringToArray($inFiltroRiesgos);
        foreach ($inFiltroRiesgos as $key => $value) {
            if ($result != '') {
                $result .= ", ";
            }
            $result .= " '" . $value . "' ";
        }
    }
    $sql = ObtenerDatosESOP($descripcion, $codigo, $result);
    $params = array();
    if (isset($_SESSION["IDACTIVIDAD"]) and $_SESSION["IDACTIVIDAD"] != '') {
        $params[":codactividad"] = $_SESSION["IDACTIVIDAD"];
    } else {
        $params[":codactividad"] = 0;
    }
    if ($codigo != '') {
        $params[":ESOP"] = '%' . $codigo . '%';
    } else {
        if ($descripcion != '') {
            $params[":descripcion"] = '%' . $descripcion . '%';
        }
    }
    $grilla = new gridAjax(10, 10);
    /*
    $title; $width = 0; $visible = true; 
    $deletedRow = false; $colHint = -1; 
    $buttonClass = ""; $actionButton = ""; 
    $cellClass = ""; $maxChars = -1; 
    $useStyleForTitle = true; $numCellHide = -1; 
    $titleHint = ""; $mostrarEspera = false;	$msgEspera = ""; 
    $inputType = "button"; $colChecked = -1; $colButtonClass = -1;
    */
    $grilla->addColumn(new columnAjax("Seleccionar", 90, true, false, -1, "XbtnSeleccionar", "", "gridColAlignCenter", -1, false, -1, "", false, "", "checkbox", 2));
    $grilla->addColumn(new columnAjax("Codigo", 75, true, false, -1, "", "", "gridColAlignCenter", -1, false, -1, "", false, ""));
    $grilla->addColumn(new columnAjax("Descripcion", 300, true, false, -1, "", "", "gridColAlignLeft", -1, false));
    $grilla->addColumn(new columnAjax("Grupo", 150, true, false, -1, "", "", "gridColAlignLeft", -1, false));
    //-----------------------------
    $columnDetalle = new columnAjax("Detalle", 0, true, false, -1, "btnDetalleRiesgo", "", "gridColAlignLeft", -1, false);
    $columnDetalle->setFunctionAjax("showDetalleRiesgo");
    $grilla->addColumn($columnDetalle);
    //-----------------------------
    $grilla->setOrderBy($ob);
    $grilla->setPageNumber($pagina);
    $grilla->setParams($params);
    $grilla->setShowProcessMessage(true);
    $grilla->setShowTotalRegistros(true);
    $grilla->setSql($sql);
    $grilla->setTableStyle("GridTableCiiu");
    $grilla->setUseTmpIframe(false);
    //funciones gridajax
    $grilla->setFuncionAjaxJS("BuscarGridDatosESOP");
    $arrayCodigos = Array_DatosESOPsoloActivos($_SESSION["IDACTIVIDAD"]);
    $grilla->setBackGroundColumns($arrayCodigos, '#3F4C6B', 1);
    $grilla->Draw();
}