Esempio n. 1
0
 function _parseXml($doc)
 {
     $parser = new xml2array($doc);
     $result = $parser->parse();
     if (!is_array($result)) {
         return debugError(4, $result);
     } else {
         // vi gider ikke have SOAP:ENVELOPE med...
         $this->result = $result[0]["children"];
         return null;
     }
 }
Esempio n. 2
0
/**
 * Conta o número de palavras
 *
 * <b>PHP Code:</b>
 * <code>
 * ztag_CountW($strThis, $strParam)
 * </code>
 *
 * <b>zTag code:</b>
 * <code>
 * $stringVar->countw()
 * </code>
 *
 * @param string $strThis conteúdo que será transformado
 * @param string $strParam parâmetros prontos para o uso na função
 *
 * @return int retorna com o número de palavras
 *
 * @since Versão 1.0
 */
function ztag_CountW($strThis, $strParam)
{
    $strPattern = "%.*?[ .!?]+%sm";
    preg_match_all($strPattern, $strThis, $Matches, PREG_OFFSET_CAPTURE);
    if (preg_last_error()) {
        debugError("<b>preg_last_error</b>:" . preg_last_error());
    }
    return count($Matches);
}
Esempio n. 3
0
/**
 * Execute a query on an InterBase database
 *
 * <code>
 * dbExecute_Firebird($firebirdSQL);
 * </code>
 *
 * @param handle $dbExecute handleId da Execute Firebird
 *
 * @see dbOpen_Firebird()
 *
 * @since 1.0
 */
function dbExecute_firebird(&$dbHandle, $dbSQL)
{
    $debugBackTrace = debug_backtrace();
    $debugFile = basename($debugBackTrace[1]["file"]);
    $debugFunction = $debugBackTrace[1]["function"];
    $dbDriver = $dbHandle[dbHandleDriver];
    $dbHandleId = $dbHandle[dbHandleId];
    $dbHost = $dbHandle[dbHandleHost];
    $dbDatabase = $dbHandle[dbHandleDatabase];
    preg_match_all("%^\\s*(?P<sql>.*?)(?P<r>\r)?(?P<n>\n)%sm", $dbSQL . "\r\n", $Matches, PREG_OFFSET_CAPTURE);
    if (preg_last_error()) {
        debugError("<b>preg_last_error</b>:" . preg_last_error());
    }
    $dbSQL = "";
    foreach ($Matches[0] as $key => $value) {
        $dbSQL .= $Matches["sql"][$key][0] . "\r\n";
    }
    if (!($firebirdExecute = @ibase_query($dbSQL, $dbHandleId))) {
        $e = ibase_errmsg();
        preg_match_all("%^(?P<origem>[^=]+)=\\s*(?P<error>-?\\d+)\\s*(?P<message>.*?)\\s*(-|at)\\s*line\\s*(?P<line>\\d+),\\s*column\\s*(?P<column>\\d+)%i", $e, $Matches, PREG_OFFSET_CAPTURE);
        $errorOrigem = $Matches["origem"][0][0];
        $errorError = $Matches["error"][0][0];
        $errorMessage = $Matches["message"][0][0];
        $errorLine = $Matches["line"][0][0];
        $errorColumn = $Matches["column"][0][0];
        echo "<span style=\"text-align: left;\"><pre><b>{$dbDriver} - {$debugFile} - {$debugFunction}()</b>:" . "<br /><b>Database</b>: " . $dbDatabase . "<br /><b>Message</b>: [" . $e . "]";
        preg_match_all("%^(?P<sql>.*?)(?P<r>\r)?(?P<n>\n)%sm", $dbSQL, $Matches, PREG_OFFSET_CAPTURE);
        if (preg_last_error()) {
            debugError("<b>preg_last_error</b>:" . preg_last_error());
        }
        $i = 0;
        $errorColumn -= 1;
        foreach ($Matches[0] as $key => $value) {
            $i++;
            $sql = $Matches["sql"][$key][0];
            echo "<br />";
            if ($i != $errorLine) {
                echo htmlentities($sql);
            } else {
                echo htmlentities(substr($sql, 0, $errorColumn)) . "<font color=\"red\"\\><b>Erro ({$errorError} - {$errorMessage})</b> --&gt; </font>" . htmlentities(substr($sql, $errorColumn, 99999));
            }
        }
        echo "<hr />" . debugBackTrace();
        echo "</pre></span>";
        die;
    }
    return $firebirdExecute;
}
Esempio n. 4
0
function zdbal_Model($tagId, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $errorMessage .= ztagParamCheck($arrParam, "id");
    $templateContent = $arrayTag[$tagId][ztagContent];
    $strLocalId = $strUse;
    $arrayTagTable = array();
    $arrayModel = array();
    $arrayModelOrder = array();
    // Compile the Model to recover all zdbal:Table tags content
    ztagCompile($templateContent, $arrayTagTable, $arrayTagId, $arrayOrder, $arrayTagLevel);
    $o = 0;
    // <zdbal:table name="TB_CONTA_MEDICA" alias="CM" primarykey="NU_CONTA_MEDICA" relates="GC:NU_CONTA_MEDICA" override="NU_CONTA_MEDICA">
    foreach ($arrayTagTable as $keyTag => $valueTag) {
        $arrTagParam = $arrayTagTable[$keyTag][ztagParam];
        $arrTagBegin = $arrayTagTable[$keyTag][ztagBegin];
        $arrTagStart = $arrayTagTable[$keyTag][ztagStart];
        $tagFunction = strtolower($valueTag[ztagFunction]);
        if (!$arrTagBegin) {
            switch ($tagFunction) {
                case "table":
                    $errorTagMessage = ztagParamCheck($arrTagParam, "name,primarykey");
                    break;
                case "view":
                    $errorTagMessage = ztagParamCheck($arrTagParam, "name");
                    break;
            }
            if ($errorTagMessage) {
                debugError("zdbal:{$tagFunction}({$arrTagStart})<br />{$errorTagMessage}");
            }
            $strTagName = $arrTagParam["name"];
            $strTagAlias = $arrTagParam["alias"];
            $strTagPrimaryKey = $arrTagParam["primarykey"];
            $strTagRelates = $arrTagParam["relates"];
            $strTagOverride = $arrTagParam["override"];
            if (!strlen($strTagAlias)) {
                $strTagAlias = $strTagName;
            }
            $arrayModelOrder[$o++] = $strTagAlias;
            if (strlen($strTagPrimaryKey)) {
                $arrayModel[$strTagAlias]["primarykey"] = $strTagPrimaryKey;
            }
            if (strlen($strTagName)) {
                $arrayModel[$strTagAlias]["name"] = $strTagName;
            }
            // Process all Relates - GC:CD_SEQUENCIA_GUIA,NU_GUIA,CM:NU_CONTA_MEDICA
            if (strlen($strTagRelates)) {
                $arrayBlock = explode(";", $strTagRelates);
                $i = 0;
                foreach ($arrayBlock as $keyBlock => $valueBlock) {
                    $arrayItem = explode(":", $valueBlock);
                    $blockAlias = $arrayItem[0];
                    $blockField = $arrayItem[1];
                    $arrayModel[$strTagAlias]["relates"][$blockAlias][$i++]["field"] = $blockField;
                }
            }
            // Process all Override - CD_SEQUENCIA_GUIA,NU_GUIA,NU_CONTA_MEDICA
            if (strlen($strTagOverride)) {
                $arrayBlock = explode(";", $strTagOverride);
                $i = 0;
                foreach ($arrayBlock as $keyBlock => $valueBlock) {
                    $arrayItem = explode(":", $valueBlock);
                    $blockAlias = $arrayItem[0];
                    $blockField = $arrayItem[1];
                    $arrayModel[$strTagAlias]["relates"][$blockAlias][$i++]["override"] = $blockField;
                }
            }
        }
    }
    $arrayTagId[$strId][ztagIdValue] = $templateContent;
    $arrayTagId[$strId][ztagIdLength] = strlen($templateContent);
    $arrayTagId[$strId][ztagIdType] = idTypeModel;
    $arrayTagId[$strId][ztagIdModel] = $arrayModel;
    $arrayTagId[$strId][ztagIdModelOrder] = $arrayModelOrder;
    ztagError($errorMessage, $arrayTag, $tagId);
}
Esempio n. 5
0
/**
 * Transforma o conteúdo de acordo as funções defindas
 *
 * <code>
 * ztagTransform("RUBEN ZEVALLOS", "sentence()->substr(1, 10)");
 * </code>
 *
 * @param string $this conteúdo que será transformado
 * @param string $strFunctions lista de funções formatadas
 *
 * @return string resultado transformado
 *
 * @since 1.0
 */
function ztagTransform($strThis, $strFunctions)
{
    // @TODO Estudar meios para evitar a inclusão de funções diferentes do sistema ou até no meio dos parâmetros.
    // Localiza as funções
    preg_match_all("%(?P<func>[\\w_]+)\\((?P<param>.*?)\\)(->|\$)%si", $strFunctions, $Matches, PREG_OFFSET_CAPTURE);
    foreach ($Matches[0] as $key => $value) {
        $myFunction = "ztag_" . strtolower($Matches["func"][$key][0]);
        $strParam = $Matches["param"][$key][0];
        $strIncludeFile = ztagFolder . "/lib/transform.inc.php";
        if (!function_exists($myFunction)) {
            if (file_exists($strIncludeFile)) {
                require_once $strIncludeFile;
            } else {
                $errorMessage .= "<br />Cannot load the libfile {$strIncludeFile}";
            }
        }
        if (function_exists($myFunction)) {
            $strThis = $myFunction($strThis, $strParam);
        } else {
            $errorMessage .= "<br />Function {$myFunction} do not exist";
        }
    }
    if ($errorMessage) {
        debugError(substr($errorMessage, 6, 999), 1);
    }
    return $strThis;
}