示例#1
0
function zdbal_SQL($tagId, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $arrayTable = array();
    $arrayTableOrder = array();
    $strId = $arrParam["id"];
    $errorMessage .= ztagParamCheck($arrParam, "id,use,model");
    $templateContent = $arrayTag[$tagId][ztagContent];
    $arrayTagField = array();
    $arrayModel = $arrayTagId[$strId][ztagIdModel];
    $arrayModelOrder = $arrayTagId[$strId][ztagIdModelOrder];
    $arrayField = array();
    // Compile the Model to recover all zdbal:Field tags content
    ztagCompile($templateContent, $arrayTagField, $arrayTagId, $arrayOrder, $arrayTagLevel);
    $o = 0;
    // <zdbal:field name="CM.CD_PESSOA_PRESTADOR" />
    foreach ($arrayTagField as $keyTag => $valueTag) {
        $arrTagParam = $arrayTagField[$keyTag][ztagParam];
        $arrTagBegin = $arrayTagField[$keyTag][ztagBegin];
        $arrTagStart = $arrayTagField[$keyTag][ztagStart];
        if (!$arrTagBegin) {
            $errorTagMessage = ztagParamCheck($arrTagParam, "name");
        }
        ztagError($errorTagMessage, $arrayTag, $tagId);
        $strTagName = $arrTagParam["name"];
        $strTagTransform = $arrTagParam["transform"];
        $intPos = strpos($strTagName, ":");
        if ($intPos) {
            $arrayField[$strTagName]["alias"] = substr($strTagName, 0, $intPos - 1);
            $arrayField[$strTagName]["name"] = substr($strTagName, $intPos + 1, strlen($strTagName));
        }
        // @TODO Gerar a query e os Joins colocando o Where e o Order by
        // @TODO processar a Query e executar o join * vezes como definido no limit.
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#2
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zserver_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zserver_zExecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strUse = $arrParam["use"];
    $strVar = $arrParam["var"];
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Get a server variable
         *
         * <code>
         * <zserver:get use="envVar" var="envVariable" />
         * </code>
         *
         * @param string use="envVar" Name of environment variable
         * @param string var="envVariable" Variable where data will be saved
         */
        case "get":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if (strlen($strVar) && isset($_SERVER[$strUse])) {
                $arrayTagId["\$" . $strVar][ztagIdValue] = $_SERVER[$strUse];
                $arrayTagId["\$" . $strVar][ztagIdLength] = count($_SERVER[$strUse]);
                $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
            }
            break;
            /*+
             * Show an server variable
             *
             * <code>
             * <zserver:show use="envVar" />
             * </code>
             *
             * @param string use="envVar" Name of environment variable
             */
        /*+
         * Show an server variable
         *
         * <code>
         * <zserver:show use="envVar" />
         * </code>
         *
         * @param string use="envVar" Name of environment variable
         */
        case "show":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if (isset($_SERVER[$strUse])) {
                $arrayTag[$tagId][ztagResult] = $_SERVER[$strUse];
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#3
0
function ztag_SQL2($tagId, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    global $dbHandleDefault;
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $errorMessage = "";
    if ($arrayTag[$tagId][ztagLegacyTag]) {
        $arrParam["template"] = $arrParam[1];
        $arrParam["where"] = $arrParam[2];
        $arrParam["orderby"] = $arrParam[3];
    }
    $strTemplate = $arrParam["template"];
    $strTimes = $arrParam["times"];
    $strModel = $arrParam["model"];
    $strWhere = $arrParam["where"];
    $strOrderBy = $arrParam["orderby"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    } else {
        if ($strTemplate) {
            $strFileName = str_replace("\\", "/", $strTemplate);
            if (strpos($strFileName, "/") === false) {
                $strFileName = "/Templates/SQL" . $strFileName . ".htm";
            }
            if ($strFileName) {
                if (substr($strFileName, 0, 1) == "/") {
                    $strFileName = substr($strFileName, 1);
                }
                $strFileName = SiteRootDir . $strFileName;
                // @TODO incluir validações mais fortes para a abertura dos arquivos
                if (!file_exists($strFileName)) {
                    $errorMessage .= "<br />File \"{$strFileName}\" not found!";
                } else {
                    $handleFile = fopen($strFileName, "r");
                    $strContent = fread($handleFile, filesize($strFileName));
                    fclose($handleFile);
                }
            }
        }
    }
    $errorMessage .= ztagParamCheck($arrParam, "where,orderby");
    echo "<pre>" . htmlentities($strContent) . "</pre>";
    /*
      FROM pubPaginas P1
      LEFT JOIN pubPaginas P2 ON P1.pagPai = P2.pagCodigo
      LEFT JOIN pubPaginas P3 ON P2.pagPai = P3.pagCodigo
      LEFT JOIN pubPaginas P4 ON P3.pagPai = P4.pagCodigo
      LEFT JOIN pubPaginas P5 ON P4.pagPai = P5.pagCodigo
      LEFT JOIN pubPaginas P6 ON P5.pagPai = P6.pagCodigo
    */
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
        $arrayTagId[$strId][ztagIdValue] = $strContent;
        $arrayTagId[$strId][ztagIdLength] = strlen($strContent);
        $arrayTagId[$strId][ztagIdType] = idTypeSQL;
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#4
0
/**
 * Main zTag functions selector
 *
 * <code>
 * znosql_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function znosql_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $strUse = $arrParam["use"];
    $strDatabase = $arrParam["database"];
    $strCollection = $arrParam["collection"];
    $strName = $arrParam["name"];
    $strValue = $arrParam["value"];
    $strVar = $arrParam["var"];
    $strTransform = $arrParam["transform"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Open connection to a NoSQL Server
         *
         * <code>
         * <znosql:open id="mongoDB" driver="Mongo" host="username:password@mongodb.zyc.com.br:27017" database="Direito2" collection="pubPaginas" />
         * <znosql:open id="mongoDB" driver="Mongo" host="mongodb.zyc.com.br" username="******" password="******" port="27017" database="Direito2" collection="pubPaginas" />
         * </code>
         *
         * @param string id="mongoDB"
         * @param string driver="Mongo"
         * @param string host="username:password@mongodb.zyc.com.br:27017" <-- mongodb://[username:password@]host1[:port1][,host2[:port2:],...]
         * @param string username="******"
         * @param string password="******"
         * @param int port="27017"
         * @param string options="option=value;option2=value2"
         * @param string database="Direito2"
         * @param string collection="pubPaginas"
         * @param boolean persist="0|1|true|false|x"
         */
        case "open":
            $strDriver = $arrParam["driver"];
            $strHost = $arrParam["host"];
            $strUsername = $arrParam["username"];
            $strPassword = $arrParam["password"];
            $strPort = $arrParam["port"];
            $strPersist = $arrParam["persist"];
            $strOptions = $arrParam["options"];
            ztagReturnConstant($strHost);
            ztagReturnConstant($strDatabase);
            ztagReturnConstant($strUsername);
            ztagReturnConstant($strPassword);
            ztagReturnConstant($strPort);
            $errorMessage .= ztagParamCheck($arrParam, "id,driver,host");
            $strDriver = constant("nosql{$strDriver}");
            if (strlen($strUsername) && strlen($strPassword)) {
                $strHost = "{$strUsername}:{$strPassword}@{$strHost}";
            }
            if (strlen($strPort)) {
                $strHost = "{$strHost}:{$strPort}";
            }
            if (strlen($strOptions)) {
                $strHost = "{$strHost}?{$strOptions}";
            }
            if (extension_loaded('mongo')) {
                try {
                    $nosqlHandle = array();
                    if ($strPersist === "true" || $strPersist === "1" || ($strPersist = "x")) {
                        $dbHandle = new Mongo($strHost, array("persist" => "x"));
                    } else {
                        $dbHandle = new Mongo($strHost);
                    }
                    if ($strDatabase) {
                        $nosqlDB = $nosqlHandle->selectDB($strDatabase);
                    }
                } catch (MongoConnectionException $e) {
                    $errorMessage .= "<br />Cannot connect to {$strDriver} (" . $e->getMessage() . ")";
                }
                if (strlen($strCollection)) {
                    $nosqlColection = $nosqlDB->selectCollection($strCollection);
                }
            } else {
                $errorMessage .= "<br />{$strDriver} extention is not installed!";
            }
            // Set all NoSQL handler structure
            $nosqlHandle[nosqlHandleDriver] = $strDriver;
            $nosqlHandle[nosqlHandleHost] = $strHost;
            $nosqlHandle[nosqlHandleDatabaseName] = $dbDatabase;
            $nosqlHandle[nosqlHandleUser] = $strUsername;
            $nosqlHandle[nosqlHandlePassword] = $strPassword;
            $nosqlHandle[nosqlHandlePort] = $strPort;
            $nosqlHandle[nosqlHandleId] = $dbHandle;
            $nosqlHandle[nosqlHandleState] = dbHandleStateOpen;
            $arrayTagId[$strId][ztagIdHandle] = $nosqlHandle;
            $arrayTagId[$strId][ztagIdType] = idTypeNoSQL;
            $arrayTagId[$strId][ztagIdState] = idStateOpened;
            break;
            /*+
             * Close a Opened NoSQL Handle connection
             *
             * <code>
             * <znosql:close use="mongoDB">
             * </code>
             *
             * @param string use="mongoDB"
             *
             */
        /*+
         * Close a Opened NoSQL Handle connection
         *
         * <code>
         * <znosql:close use="mongoDB">
         * </code>
         *
         * @param string use="mongoDB"
         *
         */
        case "close":
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    $dbHandle = $nosqlHandle[nosqlHandleId];
                    $dbHandle->close();
                    $arrayTagId[$strUse][ztagIdHandle] = $dbHandle;
                    $arrayTagId[$strUse][ztagIdState] = idStateClosed;
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Do an Insert in currente Collection
             *
             * </code>
             * <znosql:insert use="mongoDB">
             *  pagCodigo="1"
             *  , pagNome="Page \"title\""
             *  , pagResumo='Page \'resume\''
             *  , pagDescricao:"Page body"
             *  , pagPalavrasChave:{"example","NoSQL"}
             *  , pagInclusao='2010/10/10'
             *  , pagAtivo=1
             * </znosql:insert>
             *
             * <znosql:insert use="mongoDB" value="$varInsert" />
             * </code>
             *
             *  @param string use="mongoDB"
             *  @param boolean safe="true|false|1|0"
             *  @param boolean fsync="true|false|1|0"
             */
        /*+
         * Do an Insert in currente Collection
         *
         * </code>
         * <znosql:insert use="mongoDB">
         *  pagCodigo="1"
         *  , pagNome="Page \"title\""
         *  , pagResumo='Page \'resume\''
         *  , pagDescricao:"Page body"
         *  , pagPalavrasChave:{"example","NoSQL"}
         *  , pagInclusao='2010/10/10'
         *  , pagAtivo=1
         * </znosql:insert>
         *
         * <znosql:insert use="mongoDB" value="$varInsert" />
         * </code>
         *
         *  @param string use="mongoDB"
         *  @param boolean safe="true|false|1|0"
         *  @param boolean fsync="true|false|1|0"
         */
        case "insert":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleCollection]) {
                        $dbHandle = $nosqlHandle[nosqlHandleId];
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $strCollection = $nosqlHandle[nosqlHandleCollectionName];
                        $dbHandleCollection = $nosqlHandle[nosqlHandleCollection];
                        // Prepare the tag content
                        if (strlen($strContent)) {
                            $contentArray = $strContent;
                        }
                        if (strlen($strValue)) {
                            $contentArray = $strValue;
                        }
                        if (strlen($contentArray)) {
                            $contentArray = ztagVars($contentArray, $arrayTagId);
                        }
                        if (strlen($contentArray)) {
                            $contentArray = ztagRun($contentArray, 0, $arrayTagId);
                        }
                        if (!strlen($strContent) && !strlen($strValue)) {
                            $errorMessage .= ztagParamCheck($arrParam, "value");
                        }
                        if (strlen($strTransform) && strlen($contentArray)) {
                            $contentArray = ztagTransform($contentArray, $strTransform);
                        }
                        $contentArray = znosql_lib_Content2Array($contentArray);
                        // @TODO Think how to manage the safe option and it's MongoCursorException
                        try {
                            $dbResult = $dbHandleCollection->insert($contentArray);
                            // echo "<br /><pre>".print_r($contentArray, 1)."</pre>";
                            if (!strlen($dbResult)) {
                                $errorMessage .= "<br />Cannot insert into collection {$strCollection} at database {$strDatabase}  <pre>" . print_r($dbResult, 1) . "</pre>";
                            }
                        } catch (MongoException $e) {
                            $errorMessage .= "<br />Cannot insert into collection {$strCollection} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Execute a NoSQL commands
             *
             * <code>
             * <znosql:get use="mongoDB">
             *   Commands
             * </znosql:get>
             * </code>
             *
             * @param string use="mongoDB"
             *
             */
        /*+
         * Execute a NoSQL commands
         *
         * <code>
         * <znosql:get use="mongoDB">
         *   Commands
         * </znosql:get>
         * </code>
         *
         * @param string use="mongoDB"
         *
         */
        case "getone":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleCollection]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $strCollection = $nosqlHandle[nosqlHandleCollectionName];
                        $dbHandleCollection = $nosqlHandle[nosqlHandleCollection];
                        // Prepare the tag content
                        if (strlen($strContent)) {
                            $contentArray = $strContent;
                        }
                        if (strlen($strValue)) {
                            $contentArray = $strValue;
                        }
                        if (strlen($contentArray)) {
                            $contentArray = ztagVars($contentArray, $arrayTagId);
                        }
                        if (!strlen($strContent) && !strlen($strValue)) {
                            $errorMessage .= ztagParamCheck($arrParam, "value");
                        }
                        if (strlen($strTransform) && strlen($contentArray)) {
                            $contentArray = ztagTransform($contentArray, $strTransform);
                        }
                        $contentArray = ltrim($contentArray, "\r\n");
                        $contentArray = rtrim($contentArray, "\r\n");
                        preg_match_all("%criteria\\s*{(?P<criteria>(?:\\}|[^}])*?)}(\\s*,\\s*fields\\s*{(?P<fields>(?:\\}|[^}])*?)})?%", $contentArray, $Matches, PREG_OFFSET_CAPTURE);
                        $arrayCriteria = znosql_lib_Content2Array($Matches["criteria"][0][0]);
                        if ($Matches["fields"][0][0]) {
                            $arrayFields = znosql_lib_Content2Array($Matches["fields"][0][0], 1);
                        }
                        // @TODO Think how to manage the safe option and it's MongoCursorException
                        try {
                            if (count($arrayFields)) {
                                $dbResult = $dbHandleCollection->findOne($arrayCriteria, $arrayFields);
                            } else {
                                $dbResult = $dbHandleCollection->findOne($arrayCriteria);
                            }
                            if (strlen($strVar) && count($dbResult)) {
                                $arrayTagId["\$" . $strVar][ztagIdValue] = $value;
                                $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
                            }
                        } catch (MongoConnectionException $e) {
                            $errorMessage .= "<br />Cannot find the criteria into collection {$strCollection} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Execute a NoSQL commands
             *
             * <code>
             * <znosql:get use="mongoDB">
             *   Commands
             * </znosql:execute>
             * </code>
             *
             * $query - the evaluation or "where" expression
             * $orderby - sort order desired
             * $hint - hint to query optimizer
             * $explain - if true, return explain plan results instead of query results
             * $snapshot - if true, "snapshot mode"
             */
        /*+
         * Execute a NoSQL commands
         *
         * <code>
         * <znosql:get use="mongoDB">
         *   Commands
         * </znosql:execute>
         * </code>
         *
         * $query - the evaluation or "where" expression
         * $orderby - sort order desired
         * $hint - hint to query optimizer
         * $explain - if true, return explain plan results instead of query results
         * $snapshot - if true, "snapshot mode"
         */
        case "getall":
            /*$errorMessage .= ztagParamCheck($arrParam, "use");
            	    // $cursor = $this->collection->find($f);
            
            	    $k = array();
            	    $i = 0;
            
            	    while( $cursor->hasNext())
            	    {
            	        $k[$i] = $cursor->getNext();
            	      $i++;
            	    }
            
            	    // return $k;
            	     *
            	     */
            break;
            /*+
             * Do an Update in currente Collection
             *
             * <code>
             * <znosql:update use="mongoDB">
             *  criteria{pagCodigo="1"}
             *  , set{pagNome="Page \"title\" Updated"
             *  , pagResumo='Page \'resume\''
             *  , pagDescricao:"Page body"
             *  , pagPalavrasChave:{"example","NoSQL"}
             *  , pagInclusao='2010/10/10'
             *  , pagAtivo=1
             *  }
             * </znosql:update>
             *
             * <znosql:update use="mongoDB" criteria="$varCriteria" value="$varInsert" />
             * </code>
             *
             * @param string use="mongoDB"
             * @param boolean upsert="true|false|1|0"
             * @param boolean multiple="true|false|1|0"
             * @param boolean safe="true|false|1|0"
             * @param boolean fsync="true|false|1|0"
             */
        /*+
         * Do an Update in currente Collection
         *
         * <code>
         * <znosql:update use="mongoDB">
         *  criteria{pagCodigo="1"}
         *  , set{pagNome="Page \"title\" Updated"
         *  , pagResumo='Page \'resume\''
         *  , pagDescricao:"Page body"
         *  , pagPalavrasChave:{"example","NoSQL"}
         *  , pagInclusao='2010/10/10'
         *  , pagAtivo=1
         *  }
         * </znosql:update>
         *
         * <znosql:update use="mongoDB" criteria="$varCriteria" value="$varInsert" />
         * </code>
         *
         * @param string use="mongoDB"
         * @param boolean upsert="true|false|1|0"
         * @param boolean multiple="true|false|1|0"
         * @param boolean safe="true|false|1|0"
         * @param boolean fsync="true|false|1|0"
         */
        case "update":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleCollection]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $strCollection = $nosqlHandle[nosqlHandleCollectionName];
                        $dbHandleCollection = $nosqlHandle[nosqlHandleCollection];
                        // Prepare the tag content
                        if (strlen($strContent)) {
                            $contentArray = $strContent;
                        }
                        if (strlen($strValue)) {
                            $contentArray = $strValue;
                        }
                        if (strlen($contentArray)) {
                            $contentArray = ztagVars($contentArray, $arrayTagId);
                        }
                        if (!strlen($strContent) && !strlen($strValue)) {
                            $errorMessage .= ztagParamCheck($arrParam, "value");
                        }
                        if (strlen($strTransform) && strlen($contentArray)) {
                            $contentArray = ztagTransform($contentArray, $strTransform);
                        }
                        $contentArray = ltrim($contentArray, "\r\n");
                        $contentArray = rtrim($contentArray, "\r\n");
                        preg_match_all("%criteria\\s*{(?P<criteria>(?:\\}|[^}])*?)}\\s*,\\s*set\\s*{(?P<set>(?:\\}|[^}])*?)}%", $contentArray, $Matches, PREG_OFFSET_CAPTURE);
                        // echo "<br /><pre>".print_r($Matches, 1)."</pre>";
                        $arrayCriteria = znosql_lib_Content2Array($Matches["criteria"][0][0]);
                        $arraySet = array('$set' => znosql_lib_Content2Array($Matches["set"][0][0]));
                        // @TODO Think how to manage the safe option and it's MongoCursorException
                        try {
                            $dbResult = $dbHandleCollection->update($arrayCriteria, $arraySet);
                            // echo "<br /><pre>".print_r($contentArray, 1)."</pre>";
                            if (!$dbResult) {
                                $errorMessage .= "<br />Cannot update the criteria into collection {$strCollection} at database {$strDatabase}  <pre>" . print_r($dbResult, 1) . "</pre>";
                            }
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Cannot update the criteria into collection {$strCollection} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Delete a criteria at current collection
             *
             * <code>
             * <znosql:delete use="mongoDB">
             *  pagCodigo="1"
             * </znosql:delete>
             *
             * <znosql:delete use="mongoDB" criteria="$varCriteria" />
             * </code>
             *
             * @param string use="mongoDB"
             * @param boolean justone="true|false|1|0"
             * @param boolean safe="true|false|1|0"
             * @param boolean fsync="true|false|1|0"
             */
        /*+
         * Delete a criteria at current collection
         *
         * <code>
         * <znosql:delete use="mongoDB">
         *  pagCodigo="1"
         * </znosql:delete>
         *
         * <znosql:delete use="mongoDB" criteria="$varCriteria" />
         * </code>
         *
         * @param string use="mongoDB"
         * @param boolean justone="true|false|1|0"
         * @param boolean safe="true|false|1|0"
         * @param boolean fsync="true|false|1|0"
         */
        case "delete":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleCollection]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $strCollection = $nosqlHandle[nosqlHandleCollectionName];
                        $dbHandleCollection = $nosqlHandle[nosqlHandleCollection];
                        // Prepare the tag content
                        if (strlen($strContent)) {
                            $contentArray = $strContent;
                        }
                        if (strlen($strValue)) {
                            $contentArray = $strValue;
                        }
                        if (strlen($contentArray)) {
                            $contentArray = ztagVars($contentArray, $arrayTagId);
                        }
                        if (!strlen($strContent) && !strlen($strValue)) {
                            $errorMessage .= ztagParamCheck($arrParam, "value");
                        }
                        if (strlen($strTransform) && strlen($contentArray)) {
                            $contentArray = ztagTransform($contentArray, $strTransform);
                        }
                        $contentArray = znosql_lib_Content2Array($contentArray);
                        // echo "<br /><pre>contentArray=".print_r($contentArray, 1)."</pre>";
                        // @TODO Think how to manage the safe option and it's MongoCursorException
                        try {
                            $dbResult = $dbHandleCollection->remove($contentArray);
                            // echo "<br /><pre>dbResult=".print_r($dbResult, 1)."</pre>";
                            if (!$dbResult) {
                                $errorMessage .= "<br />Cannot delete the criteria into collection {$strCollection} at database {$strDatabase}  <pre>" . print_r($dbResult, 1) . "</pre>";
                            }
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Cannot delete the criteria into collection {$strCollection} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Execute a NoSQL commands
             *
             * <code>
             * <znosql:execute use="mongoDB">
             *   Commands
             * </znosql:execute>
             * </code>
             *
             * @param string use="mongoDB"
             *
             */
        /*+
         * Execute a NoSQL commands
         *
         * <code>
         * <znosql:execute use="mongoDB">
         *   Commands
         * </znosql:execute>
         * </code>
         *
         * @param string use="mongoDB"
         *
         */
        case "execute":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            // Execute Close, but I don't know yet!
            $arrayTagId[$strUse][ztagIdState] = idStateClosed;
            // mongo->execute($cmd);
            break;
            /*+
             * Set a database for current Opened NoSQL connection
             *
             * <code>
             * <znosql:setdatabase use="mongoDB" name="Direito2" />
             * </code>
             *
             * @param string use="mongoDB"
             * @param string name="Direito2" The database name.
             */
        /*+
         * Set a database for current Opened NoSQL connection
         *
         * <code>
         * <znosql:setdatabase use="mongoDB" name="Direito2" />
         * </code>
         *
         * @param string use="mongoDB"
         * @param string name="Direito2" The database name.
         */
        case "setdatabase":
            $errorMessage .= ztagParamCheck($arrParam, "use,name");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    $dbHandle = $nosqlHandle[nosqlHandleId];
                    try {
                        $dbHandleDatabase = $dbHandle->selectDB($strName);
                        $nosqlHandle[nosqlHandleDatabaseName] = $strName;
                        $nosqlHandle[nosqlHandleDatabase] = $dbHandleDatabase;
                    } catch (InvalidArgumentException $e) {
                        $errorMessage .= "<br />Invalid database name {$strName} (" . $e->getMessage() . ")";
                    }
                    $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * List all databases
             *
             * <code>
             * <znosql:listdatabases use="mongoDB" id="mongoDBlist" var="databasesList" total="databasesTotalSize">
             *   <br /><znosql:field use="mongoDBlist" name="name" /> - <znosql:field use="mongoDBlist" name="sizeOnDisk" /> - <znosql:field use="mongoDBlist" name="empty" />
             * </znosql:listdatabases>
             * </code>
             *
             * @param string use="mongoDB" A NoSQL handle
             * @param string id="mongoDBlist" Id with array of each line
             * @param string var="databasesList" Variable with array of each line
             * @param string total="databasesTotalSize" Variable with total size
             */
        /*+
         * List all databases
         *
         * <code>
         * <znosql:listdatabases use="mongoDB" id="mongoDBlist" var="databasesList" total="databasesTotalSize">
         *   <br /><znosql:field use="mongoDBlist" name="name" /> - <znosql:field use="mongoDBlist" name="sizeOnDisk" /> - <znosql:field use="mongoDBlist" name="empty" />
         * </znosql:listdatabases>
         * </code>
         *
         * @param string use="mongoDB" A NoSQL handle
         * @param string id="mongoDBlist" Id with array of each line
         * @param string var="databasesList" Variable with array of each line
         * @param string total="databasesTotalSize" Variable with total size
         */
        case "listdatabases":
            $strTotal = $arrParam["total"];
            $errorMessage .= ztagParamCheck($arrParam, "use,id");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    $dbHandle = $nosqlHandle[nosqlHandleId];
                    $arrayDatabases = $dbHandle->listDBs();
                    $totalDbSize = $arrayDatabases['totalSize'];
                    foreach ($arrayDatabases["databases"] as $key => $value) {
                        if (strlen($strId)) {
                            $arrayTagId[$strId][ztagIdValue] = $arrayDatabases["databases"][$key];
                            $arrayTagId[$strId][ztagIdType] = idTypeValue;
                        }
                        if (strlen($strVar)) {
                            $arrayTagId["\$" . $strVar][ztagIdValue] = $arrayDatabases["databases"][$key];
                            $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
                        }
                        $strResult = ztagRun($strContent, 0, $arrayTagId);
                        $arrayTag[$tagId][ztagResult] .= $strResult;
                    }
                    if (strlen($strTotal)) {
                        $arrayTagId["\$" . $strTotal][ztagIdValue] = $arrayDatabases[totalSize];
                        $arrayTagId["\$" . $strTotal][ztagIdType] = idTypeFVar;
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Return the server Stats
             *
             * <code>
             * <znosql:getstats use="mongoDB" var="mongoStats" />
             * </code>
             *
             * @param string use="mongoDB"
             * @param string var="mongoStats"
             */
        /*+
         * Return the server Stats
         *
         * <code>
         * <znosql:getstats use="mongoDB" var="mongoStats" />
         * </code>
         *
         * @param string use="mongoDB"
         * @param string var="mongoStats"
         */
        case "getstats":
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    $dbHandle = $nosqlHandle[nosqlHandleId];
                    $arrayDatabases = $dbHandle->listDBs();
                    $dbHandleAdmin = $dbHandle->selectDB('admin');
                    $arrayReturn = array_merge($dbHandleAdmin->command(array('buildinfo' => 1)), $dbHandleAdmin->command(array('serverStatus' => 1)));
                    $profile = $dbHandleAdmin->command(array('profile' => -1));
                    $arrayReturn['profilingLevel'] = $profile['was'];
                    $arrayReturn['mongoDbTotalSize'] = round($totalDbSize / 1000000) . 'mb';
                    $prevError = $dbHandleAdmin->command(array('getpreverror' => 1));
                    if (!$prevError['n']) {
                        $arrayReturn['previousDbErrors'] = 'None';
                    } else {
                        $arrayReturn['previousDbErrors']['error'] = $prevError['err'];
                        $arrayReturn['previousDbErrors']['numberOfOperationsAgo'] = $prevError['nPrev'];
                    }
                    $arrayReturn['globalLock']['totalTime'] .= ' &#0181;Sec';
                    $arrayReturn['uptime'] = round($arrayReturn['uptime'] / 60) . ':' . str_pad($arrayReturn['uptime'] % 60, 2, '0', STR_PAD_LEFT) . ' minutes';
                    $arrayUnshift['mongo'] = $arrayReturn['version'] . ' (' . $arrayReturn['bits'] . '-bit)';
                    $arrayUnshift['mongoPhpDriver'] = Mongo::VERSION;
                    $arrayUnshift['phpMoAdmin'] = '1.0.8';
                    $arrayUnshift['php'] = PHP_VERSION . ' (' . (PHP_INT_MAX > 2200000000.0 ? 64 : 32) . '-bit)';
                    $arrayUnshift['gitVersion'] = $arrayReturn['gitVersion'];
                    unset($arrayReturn['ok'], $arrayReturn['version'], $arrayReturn['gitVersion'], $arrayReturn['bits']);
                    $arrayReturn = array_merge(array('version' => $arrayUnshift), $arrayReturn);
                    $iniIndex = array(-1 => 'Unlimited', 'Off', 'On');
                    $phpIni = array('allow_persistent', 'auto_reconnect', 'chunk_size', 'cmd', 'default_host', 'default_port', 'max_connections', 'max_persistent');
                    foreach ($phpIni as $ini) {
                        $key = 'php_' . $ini;
                        $arrayReturn[$key] = ini_get('mongo.' . $ini);
                        if (isset($iniIndex[$arrayReturn[$key]])) {
                            $arrayReturn[$key] = $iniIndex[$arrayReturn[$key]];
                        }
                    }
                    if (strlen($strVar)) {
                        $arrayTagId["\$" . $strVar][ztagIdValue] = $arrayReturn;
                        $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Repair the current Database
             *
             * <code>
             * <znosql:repairdatabase use="mongoDB" preserveclonedfiles="true" backuporiginalfiles="true" />
             * </code>
             *
             * @param boolean preserveclonedfiles="true|false|1|0"
             * @param boolean backuporiginalfiles="true|false|1|0"
             */
        /*+
         * Repair the current Database
         *
         * <code>
         * <znosql:repairdatabase use="mongoDB" preserveclonedfiles="true" backuporiginalfiles="true" />
         * </code>
         *
         * @param boolean preserveclonedfiles="true|false|1|0"
         * @param boolean backuporiginalfiles="true|false|1|0"
         */
        case "repairdatabase":
            $strPreserveClonedFiles = $arrParam["preserveclonedfiles"];
            $strBackupOriginalFiles = $arrParam["backuporiginalfiles"];
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleDatabase]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $dbHandleDatabase = $nosqlHandle[nosqlHandleDatabase];
                        try {
                            if ($strPreserveClonedFiles === "true" || $strPreserveClonedFiles === "1") {
                                $strPreserveClonedFiles = true;
                            }
                            if ($strBackupOriginalFiles === "true" || $strBackupOriginalFiles === "1") {
                                $strBackupOriginalFiles = true;
                            }
                            if (strlen($strPreserveClonedFiles) && !strlen($strBackupOriginalFiles)) {
                                $dbResult = $dbHandleDatabase->repair($strPreserveClonedFiles);
                            } elseif (strlen($strBackupOriginalFiles)) {
                                $dbResult = $dbHandleDatabase->repair($strPreserveClonedFiles, $strBackupOriginalFiles);
                            } else {
                                $dbResult = $dbHandleDatabase->repair();
                            }
                            if ($dbResult["ok"] != 1) {
                                $errorMessage .= "<br />Cannot repair the {$strDatabase} <pre>" . print_r($dbResult, 1) . "</pre>";
                            }
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Invalid database name {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Drop current database
             *
             * <code>
             * <znosql:dropdatabase use="mongoDB" />
             * </code>
             *
             * @param string use="mongoDB"
             */
        /*+
         * Drop current database
         *
         * <code>
         * <znosql:dropdatabase use="mongoDB" />
         * </code>
         *
         * @param string use="mongoDB"
         */
        case "dropdatabase":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleDatabase]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $dbHandleDatabase = $nosqlHandle[nosqlHandleDatabase];
                        try {
                            $dbResult = $dbHandleDatabase->drop();
                            if ($dbResult["ok"] == 1) {
                                $nosqlHandle[nosqlHandleDatabaseName] = null;
                                $nosqlHandle[nosqlHandleDatabase] = null;
                            } else {
                                $errorMessage .= "<br />Cannot drop the database {$strDatabase} <pre>" . print_r($dbResult, 1) . "</pre>";
                            }
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Cannot drop the database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Set a collection for current database
             *
             * <code>
             * <znosql:setcollection use="mongoDB" name="pubPaginas" />
             * </code>
             *
             * @param string use="mongoDB"
             * @param string name="pubPaginas"
             */
        /*+
         * Set a collection for current database
         *
         * <code>
         * <znosql:setcollection use="mongoDB" name="pubPaginas" />
         * </code>
         *
         * @param string use="mongoDB"
         * @param string name="pubPaginas"
         */
        case "setcollection":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleDatabase]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $dbHandleDatabase = $nosqlHandle[nosqlHandleDatabase];
                        try {
                            $dbHandleCollection = $dbHandleDatabase->selectCollection($strName);
                            $nosqlHandle[nosqlHandleCollectionName] = $strName;
                            $nosqlHandle[nosqlHandleCollection] = $dbHandleCollection;
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Invalid collection name {$strName} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * List all databases
             *
             * <code>
             * <znosql:listcollections use="mongoDB" id="mongoDBlist" var="databasesList" total="databasesTotalSize">
             *   <br /><znosql:field use="mongoDBlist" name="name" /> - <znosql:field use="mongoDBlist" name="sizeOnDisk" /> - <znosql:field use="mongoDBlist" name="empty" />
             * </znosql:listcollections>
             * </code>
             *
             * @param string use="mongoDB" A NoSQL handle
             * @param string id="mongoDBlist" Id with array of each line
             * @param string var="databasesList" Variable with array of each line
             * @param string total="databasesTotalSize" Variable with total size
             */
        /*+
         * List all databases
         *
         * <code>
         * <znosql:listcollections use="mongoDB" id="mongoDBlist" var="databasesList" total="databasesTotalSize">
         *   <br /><znosql:field use="mongoDBlist" name="name" /> - <znosql:field use="mongoDBlist" name="sizeOnDisk" /> - <znosql:field use="mongoDBlist" name="empty" />
         * </znosql:listcollections>
         * </code>
         *
         * @param string use="mongoDB" A NoSQL handle
         * @param string id="mongoDBlist" Id with array of each line
         * @param string var="databasesList" Variable with array of each line
         * @param string total="databasesTotalSize" Variable with total size
         */
        case "listcollections":
            $strTotal = $arrParam["total"];
            $errorMessage .= ztagParamCheck($arrParam, "use,id");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleDatabase]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $dbHandleDatabase = $nosqlHandle[nosqlHandleDatabase];
                        $arrayCollections = $dbHandleDatabase->listCollections();
                        foreach ($arrayCollections as $dbHandleCollecion) {
                            if ($strId) {
                                $arrayTagId[$strId][ztagIdValue] = array("name" => $dbHandleCollecion->getName());
                                $arrayTagId[$strId][ztagIdType] = idTypeValue;
                            }
                            if ($strVar) {
                                $arrayTagId["\$" . $strVar][ztagIdValue] = array("name" => $dbHandleCollecion->getName());
                                $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
                            }
                            $strResult = ztagRun($strContent, 0, $arrayTagId);
                            $arrayTag[$tagId][ztagResult] .= $strResult;
                        }
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Drop a collection for current database
             *
             * <code>
             * <znosql:dropcollection use="mongoDB" />
             * </code>
             *
             * @param string use="mongoDB"
             */
        /*+
         * Drop a collection for current database
         *
         * <code>
         * <znosql:dropcollection use="mongoDB" />
         * </code>
         *
         * @param string use="mongoDB"
         */
        case "dropcollection":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleCollection]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $strCollection = $nosqlHandle[nosqlHandleCollectionName];
                        $dbHandleCollection = $nosqlHandle[nosqlHandleCollection];
                        try {
                            $dbResult = $dbHandleCollection->drop();
                            if ($dbResult["ok"] == 1) {
                                $nosqlHandle[nosqlHandleCollectionName] = null;
                                $nosqlHandle[nosqlHandleCollection] = null;
                            } else {
                                $errorMessage .= "<br />Cannot drop the collection {$strCollection} at database {$strDatabase}  <pre>" . print_r($dbResult, 1) . "</pre>";
                            }
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Cannot drop the collection {$strCollection} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Create a collection for current database
             *
             * </code>
             * <znosql:createcollection use="mongoDB" name="pubPaginas" />
             * </code>
             *
             * @param string use="mongoDB"
             * @param string name="pubPaginas" The name of the collection.
             * @param boolean capped="true|false|1|0" If the collection should be a fixed size.
             * @param int  size="10000000" If the collection is fixed size, its size in bytes.
             * @param int max="1000" If the collection is fixed size, the maximum number of elements to store in the collection.
             */
        /*+
         * Create a collection for current database
         *
         * </code>
         * <znosql:createcollection use="mongoDB" name="pubPaginas" />
         * </code>
         *
         * @param string use="mongoDB"
         * @param string name="pubPaginas" The name of the collection.
         * @param boolean capped="true|false|1|0" If the collection should be a fixed size.
         * @param int  size="10000000" If the collection is fixed size, its size in bytes.
         * @param int max="1000" If the collection is fixed size, the maximum number of elements to store in the collection.
         */
        case "createcollection":
            $errorMessage .= ztagParamCheck($arrParam, "use,name");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleDatabase]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $dbHandleDatabase = $nosqlHandle[nosqlHandleDatabase];
                        try {
                            $dbHandleCollection = $dbHandleDatabase->createCollection($strName);
                            $nosqlHandle[nosqlHandleCollectionName] = $strName;
                            $nosqlHandle[nosqlHandleCollection] = $dbHandleCollection;
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Cannot create the collection {$strName} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Create a collection for current database
             *
             * <code>
             * <znosql:createcollection use="mongoDB" from="pubPaginas" to="pubPaginasOld"/>
             * </code>
             *
             * @param string use="mongoDB"
             * @param string from="pubPaginas"
             * @param string to="pubPaginasOld"
             */
        /*+
         * Create a collection for current database
         *
         * <code>
         * <znosql:createcollection use="mongoDB" from="pubPaginas" to="pubPaginasOld"/>
         * </code>
         *
         * @param string use="mongoDB"
         * @param string from="pubPaginas"
         * @param string to="pubPaginasOld"
         */
        case "renamecollection":
            $strFrom = $arrParam["from"];
            $strTo = $arrParam["to"];
            $errorMessage .= ztagParamCheck($arrParam, "use,name");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    $dbHandle = $nosqlHandle[nosqlHandleId];
                    if ($nosqlHandle[nosqlHandleDatabase]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $dbResult = $dbHandle->selectDB('admin')->command(array('renameCollection' => "{$strDatabase}.{$strFrom}", 'to' => "{$strDatabase}.{$strTo}"));
                        echo "<pre>" . print_r($dbResult, 1) . "</pre>";
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * List all indexes for a Collection
             *
             * <code>
             * <znosql:listindexes use="mongoDB" collection="pubPaginas" />
             * </code>
             *
             * @param string use="mongoDB"
             * @param string collection="pubPaginas"
             */
        /*+
         * List all indexes for a Collection
         *
         * <code>
         * <znosql:listindexes use="mongoDB" collection="pubPaginas" />
         * </code>
         *
         * @param string use="mongoDB"
         * @param string collection="pubPaginas"
         */
        case "listindexes":
            return $this->mongo->selectCollection($collection)->getIndexInfo();
            break;
            /*+
             * Ensure a index of current collection
             *
             * <code>
             * <znosql:ensureindex use="mongoDB" />
             * </code>
             *
             * @param string use="mongoDB"
             */
        /*+
         * Ensure a index of current collection
         *
         * <code>
         * <znosql:ensureindex use="mongoDB" />
         * </code>
         *
         * @param string use="mongoDB"
         */
        case "ensureindex":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeNoSQL) {
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $nosqlHandle = $arrayTagId[$strUse][ztagIdHandle];
                    if ($nosqlHandle[nosqlHandleCollection]) {
                        $strDatabase = $nosqlHandle[nosqlHandleDatabaseName];
                        $strCollection = $nosqlHandle[nosqlHandleCollectionName];
                        $dbHandleCollection = $nosqlHandle[nosqlHandleCollection];
                        try {
                            $dbResult = $dbHandleCollection->ensureIndex();
                            $unique = $unique ? true : false;
                            //signature requires a bool in both Mongo v. 1.0.1 and 1.2.0
                            // mongo->selectCollection($collection)->ensureIndex($indexes, $unique);
                            if ($dbResult["ok"] == 1) {
                                $nosqlHandle[nosqlHandleCollectionName] = null;
                                $nosqlHandle[nosqlHandleCollection] = null;
                            } else {
                                $errorMessage .= "<br />Cannot drop the collection {$strCollection} at database {$strDatabase}  <pre>" . print_r($dbResult, 1) . "</pre>";
                            }
                        } catch (InvalidArgumentException $e) {
                            $errorMessage .= "<br />Cannot drop the collection {$strCollection} at database {$strDatabase} (" . $e->getMessage() . ")";
                        }
                        $arrayTagId[$strUse][ztagIdHandle] = $nosqlHandle;
                    } else {
                        $errorMessage .= "<br />The {$strUse} NoSQL handler do not have a database defined!";
                    }
                } else {
                    $errorMessage .= "<br />The {$strUse} NoSQL handler is not Open!";
                }
            } else {
                $errorMessage .= "<br />The {$strUse} type is not a NoSQL!";
            }
            break;
            /*+
             * Delete a index for a Collection
             *
             * <code>
             * <znosql:deleteindex use="mongoDB" collection="pubPaginas" index="pagNome"/>
             * </code>
             *
             * @param string use="mongoDB"
             * @param string collection="pubPaginas"
             * @param string index="pagNome"
             *
             */
        /*+
         * Delete a index for a Collection
         *
         * <code>
         * <znosql:deleteindex use="mongoDB" collection="pubPaginas" index="pagNome"/>
         * </code>
         *
         * @param string use="mongoDB"
         * @param string collection="pubPaginas"
         * @param string index="pagNome"
         *
         */
        case "deleteindex":
            // mongo->selectCollection($collection)->deleteIndex($index);
            break;
            /*+
             * Return the content of name field of current record
             *
             * </code>
             * <zdb:field use="mongoDBlist" name="name" />
             * </code>
             *
             * @param string use="mongoDBlist" - The Id Handle from current array
             * @param string name="name"
             */
        /*+
         * Return the content of name field of current record
         *
         * </code>
         * <zdb:field use="mongoDBlist" name="name" />
         * </code>
         *
         * @param string use="mongoDBlist" - The Id Handle from current array
         * @param string name="name"
         */
        case "field":
            $strVar = $arrParam["var"];
            $errorMessage .= ztagParamCheck($arrParam, "use,name");
            $fieldArray = $arrayTagId[$strUse][ztagIdValue];
            $fieldValue = $fieldArray[$strName];
            if (strlen($strTransform)) {
                $fieldValue = ztagTransform($fieldValue, $strTransform);
            }
            if (strlen($strVar)) {
                $arrayTagId["\$" . $strVar][ztagIdValue] = $fieldValue;
                $arrayTagId["\$" . $strVar][ztagIdType] = idTypeField;
            }
            $arrayTag[$tagId][ztagResult] = $fieldValue;
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#5
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zenv_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zenv_zExecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strName = $arrParam["name"];
    $strValue = $arrParam["value"];
    $strVar = $arrParam["var"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Set an environment variable
         *
         * <code>
         * <zenv:set name="envVar" value="envContent" />
         * </code>
         *
         * @param string name="envVar" Name of environment variable
         * @param string value="envContent" Content to be saved
         */
        case "set":
            $errorMessage .= ztagParamCheck($arrParam, "name,value");
            if (strlen($strName) && strlen($strValue)) {
                putenv("{$strName}={$strValue}");
            }
            break;
            /*+
             * Get an environment variable
             *
             * <code>
             * <zenv:get use="envVar" var="envVariable" />
             * </code>
             *
             * @param string use="envVar" Name of environment variable
             * @param string var="envVariable" Variable where data will be saved
             */
        /*+
         * Get an environment variable
         *
         * <code>
         * <zenv:get use="envVar" var="envVariable" />
         * </code>
         *
         * @param string use="envVar" Name of environment variable
         * @param string var="envVariable" Variable where data will be saved
         */
        case "get":
            $errorMessage .= ztagParamCheck($arrParam, "use,value");
            if (strlen($strVar) && isset($_ENV[$strUse])) {
                $arrayTagId["\$" . $strVar][ztagIdValue] = getenv($strUse);
                $arrayTagId["\$" . $strVar][ztagIdLength] = count(getenv($strUse));
                $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
            }
            break;
            /*+
             * Show an environment variable
             *
             * <code>
             * <zenv:show use="envVar" />
             * </code>
             *
             * @param string use="envVar" Name of environment variable
             */
        /*+
         * Show an environment variable
         *
         * <code>
         * <zenv:show use="envVar" />
         * </code>
         *
         * @param string use="envVar" Name of environment variable
         */
        case "show":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if (isset($_ENV[$strName])) {
                $arrayTag[$tagId][ztagResult] = $_ENV[$strUse];
            }
            break;
        default:
            $strMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#6
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zheader_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zheader_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strUse = $arrParam["use"];
    $strValue = $arrParam["value"];
    $errorMessage = "";
    $tagValue = $arrayTagId[$strParam][ztagIdValue];
    switch (strtolower($tagFunction)) {
        /*+
         * Location IF
         *
         * <code>
         * <zheader:locationif use="!userLogged" notcondition="nome" value="/logOn.php" />
         * </code>
         *
         * @param string use="!userLogged"
         * @param string notcondition="nome"
         * @param string value="/logOn.php"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "locationif":
            // @TODO Rever esta Função, criando algo mais genérico
            $strEqual = $arrParam["equal"];
            $strNotEqual = $arrParam["notequal"];
            $strCondition = $arrParam["condition"];
            $strNotCondition = $arrParam["notcondition"];
            // header("Location: /logOn.php");
            $errorMessage .= ztagParamCheck($arrParam, "use,value");
            if ($strEqual) {
                if ($strUse == $strEqual) {
                    header("Location: {$strValue}");
                }
            }
            if ($strNotEqual) {
                if ($strUse != $strNotEqual) {
                    header("Location: {$strValue}");
                }
            }
            if ($strCondition) {
                $strCondition = ztagTransform($strUse, $strCondition);
                if ($strCondition) {
                    header("Location: {$strValue}");
                }
            }
            if ($strNotCondition) {
                $strNotCondition = ztagTransform($strUse, $strNotCondition);
                if (!$strNotCondition) {
                    header("Location: {$strValue}");
                }
            }
            break;
            /*+
             * Location
             *
             * <code>
             * <zheader:location value="/logOn.php" />
             * </code>
             *
             * @param string value="/logOn.php"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Location
         *
         * <code>
         * <zheader:location value="/logOn.php" />
         * </code>
         *
         * @param string value="/logOn.php"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "location":
            // header("Location: /logOn.php");
            $errorMessage .= ztagParamCheck($arrParam, "value");
            if (strlen($strValue)) {
                header("Location: {$strValue}");
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    /*
      debugError("tagFunction=$tagFunction"
    ."<br />tagId=$tagId"
    ."<br />strId=$strId"
    ."<br />strUse=$strUse"
    ."<br />strValue=$strValue"
    ."<br />arrayTagId[$strId][ztagIdValue]=".$arrayTagId[$strId][ztagIdValue]
    ."<br />arrayTagId[$strUse][ztagIdValue]=".$arrayTagId[$strUse][ztagIdValue]
    ."<br />arrayTag[$tagId][ztagResult]=".$arrayTag[$tagId][ztagResult]);
    */
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#7
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zfile_zexecute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zfile_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $strUse = $arrParam["use"];
    $strValue = $arrParam["value"];
    $strVar = $arrParam["var"];
    $strLength = $arrParam["length"];
    $errorMessage = "";
    $tagValue = $arrayTagId[$strParam][ztagIdValue];
    /*
    if (file_exists($strFileName)) {
      // fopen  ( string $filename  , string $mode  [, bool $use_include_path = false  [, resource $context  ]] )
      $objFile = fopen($strFileName, "r");
    
      $strResult = fread($objFile, filesize($strFileName));
    
      fclose($objFile);
    }
    */
    switch (strtolower($tagFunction)) {
        /*+
         * Open
         *
         * <code>
         * <zdoc:open />
         * </code>
         *
         * @param string filename="string"
         * @param string mode="string"
         * @param string includepath="string"
         * @param string contexts="string"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "open":
            $errorMessage .= ztagParamCheck($arrParam, "id,filename,mode");
            $strFileName = $arrParam["filename"];
            $strMode = $arrParam["mode"];
            $strIncludePath = $arrParam["includepath"];
            $strContexts = $arrParam["contexts"];
            $intTest = 0;
            if (strlen($strIncludePath)) {
                $intTest = 1;
            }
            if ($strContexts) {
                $intTest = 2;
            }
            // @TODO Utilizar algum outro meio mais eficiente para verificar se a varíavel foi definida com 0 ou false
            if ($strFileName) {
                $strFileName = str_replace("\\", "/", $strFileName);
                if (substr($strFileName, 0, 1) == "/") {
                    $strFileName = substr($strFileName, 1);
                }
                $strFileName = SiteRootDir . $strFileName;
                // @TODO incluir validações mais fortes para a abertura dos arquivos
                if (!file_exists($strFileName)) {
                    $errorMessage .= "<br />File \"{$strFileName}\" not found!";
                }
            }
            if (!strlen($strIncludePath) && $intTest >= 1) {
                $errorMessage .= "<br />Missing \"includepath\" parameter";
            }
            if (!$strContexts && $intTest >= 2) {
                $errorMessage .= "<br />Missing \"contexts\" parameter";
            }
            // debugError("strFileName=$strFileName");
            switch ($intTest) {
                case 1:
                    $handleFile = fopen($strFileName, $strMode, $strIncludePath);
                    break;
                case 1:
                    $handleFile = fopen($strFileName, $strMode, $strIncludePath, $strContexts);
                    break;
                default:
                    $handleFile = fopen($strFileName, $strMode);
            }
            $arrayTagId[$strId][ztagIdHandle] = $handleFile;
            $arrayTagId[$strId][ztagIdType] = idTypeFile;
            $arrayTagId[$strId][ztagIdState] = idStateOpened;
            $arrayTagId[$strId][ztagIdFileName] = $strFileName;
            break;
            /*+
             * Read
             *
             * <code>
             * <zdoc:read />
             * </code>
             *
             * @param string  filename="string"
             * @param string  mode="string"
             * @param string  includepath="string"
             * @param string  contexts="string"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Read
         *
         * <code>
         * <zdoc:read />
         * </code>
         *
         * @param string  filename="string"
         * @param string  mode="string"
         * @param string  includepath="string"
         * @param string  contexts="string"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "read":
            $errorMessage .= ztagParamCheck($arrParam, "use,length");
            if ($arrayTagId[$strUse][ztagIdType] != idTypeFile) {
                $errorMessage .= "<br />The handle \"{$strUse}\" is not a file one!";
            }
            $handleFile = $arrayTagId[$strUse][ztagIdHandle];
            $strFileName = $arrayTagId[$strUse][ztagIdFileName];
            $strValue = fread($handleFile, strval($strLength));
            if ($strVar) {
                $arrayTagId[$strVar][ztagIdValue] = $strValue;
                $arrayTagId[$strVar][ztagIdLength] = strlen($strValue);
            }
            break;
            /*+
             * ReadAll
             *
             * <code>
             * <zdoc:readall />
             * </code>
             *
             * @param string  filename="string"
             * @param string  mode="string"
             * @param string  includepath="string"
             * @param string  contexts="string"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * ReadAll
         *
         * <code>
         * <zdoc:readall />
         * </code>
         *
         * @param string  filename="string"
         * @param string  mode="string"
         * @param string  includepath="string"
         * @param string  contexts="string"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "readall":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] != idTypeFile) {
                $errorMessage .= "<br />The handle \"{$strUse}\" is not a file one!";
            }
            $handleFile = $arrayTagId[$strUse][ztagIdHandle];
            $strFileName = $arrayTagId[$strUse][ztagIdFileName];
            $strValue = fread($handleFile, filesize($strFileName));
            if ($strVar) {
                $arrayTagId["\$" . $strVar][ztagIdValue] = $strValue;
                $arrayTagId[$strVar][ztagIdLength] = strlen($strValue);
            }
            break;
            /*+
             * Close
             *
             * <code>
             * <zdoc:close />
             * </code>
             *
             * @param string filename="string"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Close
         *
         * <code>
         * <zdoc:close />
         * </code>
         *
         * @param string filename="string"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "close":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] != idTypeFile) {
                $errorMessage .= "<br />The handle \"{$strUse}\" is not a file one!";
            }
            $handleFile = $arrayTagId[$strUse][ztagIdHandle];
            fclose($handleFile);
            $arrayTagId[$strUse][ztagIdState] = idStateClosed;
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#8
0
function zlayout_execute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    global $layoutLastCreateId;
    global $layoutColumnOrder;
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $strUse = $arrParam["use"];
    $strName = $arrParam["name"];
    $strTransform = $arrParam["transform"];
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Create
         *
         * <code>
         * <zlayout:create id="ociPrestador" headtag="th" celltag="td">
         * </code>
         *
         * @param string id="ociPrestador"
         * @param string headtag="th"
         * @param string celltag="td"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "create":
            $errorMessage .= ztagParamCheck($arrParam, "id");
            $layoutLastCreateId = $strId;
            $layoutColumnOrder[$strId] = 0;
            if ($arrayTag[$tagId][ztagContentWidth]) {
                $strContent = $arrayTag[$tagId][ztagContent];
                $arrayTagId[$strId][ztagIdValue] = $strContent;
                $arrayTagId[$strId][ztagIdLength] = strlen($strValue);
                $arrayTagId[$strId][ztagIdType] = idTypeLayout;
                if ($arrParam["headtag"]) {
                    $arrayTagId[$strId][layoutTypeDefault][layouHeadTag] = $arrParam["headtag"];
                }
                if ($arrParam["celltag"]) {
                    $arrayTagId[$strId][layoutTypeDefault][layouCellTag] = $arrParam["celltag"];
                }
                ztagRun($strContent, 0, $arrayTagId);
                echo "<pre>";
                print_r($arrayTagId);
            }
            break;
            /*+
             * Column
             *
             * <code>
             * <zlayout:column use="ociPrestador" name="NM_PESSOA" caption="Nome" headstyle="C,U" bodystyle="R" transform="sentence()" />
             * </code>
             *
             * @param string use="ociPrestador"
             * @param string name="NM_PESSOA"
             * @param string caption="Nome"
             * @param string headstyle="C,U"
             * @param string bodystyle="R"
             * @param string transform="sentence()"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Column
         *
         * <code>
         * <zlayout:column use="ociPrestador" name="NM_PESSOA" caption="Nome" headstyle="C,U" bodystyle="R" transform="sentence()" />
         * </code>
         *
         * @param string use="ociPrestador"
         * @param string name="NM_PESSOA"
         * @param string caption="Nome"
         * @param string headstyle="C,U"
         * @param string bodystyle="R"
         * @param string transform="sentence()"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "column":
            if (!$strUse) {
                $arrParam["use"] = $layoutLastCreateId;
            }
            $strUse = $arrParam["use"];
            $strCaption = $arrParam["caption"];
            $strHeadStyle = $arrParam["headstyle"];
            $strBodyStyle = $arrParam["bodystyle"];
            $errorMessage .= ztagParamCheck($arrParam, "use,name");
            if ($arrayTagId[$strUse][ztagIdType] == idTypeLayout) {
                $arrLayout = $arrayTagId[$strUse][ztagIdLayout];
                $intOrder = $layoutColumnOrder[$strUse]++;
                $arrLayout[$strName][layoutTypeOrder][$intOrder] = $strName;
                if (!$strCaption) {
                    $strCaption = $strName;
                }
                $arrLayout[$strName][layoutTypeHeader][layouCaption] = $strCaption;
                $arrLayout[$strName][layoutTypeHeader][layoutStyle] = $strHeadStyle;
                $arrLayout[$strName][layoutTypeBody][layoutStyle] = $strBodyStyle;
                $arrLayout[$strName][layoutTypeBody][layouTransform] = $strTransform;
                // unset($arrayTagId[$strId][ztagIdLayout]);
                $arrayTagId[$strUse][ztagIdLayout] = $arrLayout;
            } else {
                $errorMessage .= "<br />The id \"{$strUse}\" is not a layout type";
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#9
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zemanuel_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zemanuel_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strValue = $arrParam["value"];
    $strVar = $arrParam["var"];
    $strTransform = $arrParam["transform"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        // <zemanuel:open id="mysqlConn" driver="mysql" host="@@mysqlHost" database="@@mysqlDatabase" user="******", password="******" />
        // <zemanuel:open id="sqliteConn" driver="sqlite" filename="/ZTag/SQLite.db" />
        case "oi":
            // echo "<pre>".print_r($arrayTag[$tagId], 1)."</pre>";
            if ($strContent) {
                if ($strTransform) {
                    $strContent = ztagTransform($strContent, $strTransform);
                }
                $arrayTag[$tagId][ztagResult] = "<b>{$strContent}</b>";
            }
            if ($strValue) {
                if ($strTransform) {
                    $strValue = ztagTransform($strValue, $strTransform);
                }
                $arrayTag[$tagId][ztagResult] = "<u>{$strValue}</u>";
            }
            if ($strVar) {
                if ($strTransform) {
                    $strVar = ztagTransform($strVar, $strTransform);
                }
                $arrayTag[$tagId][ztagResult] = "<i>{$strVar}</i>";
            } else {
                if (!$strContent && !$strValue) {
                    $errorMessage .= ztagParamCheck($arrParam, "value");
                }
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
function ztagtemplatefile_test($tagId, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strValue = $arrParam["value"];
    $strVar = $arrParam["var"];
    $templateContent = $arrayTag[$tagId][ztagContent];
    if ($strContent) {
        if ($strTransform) {
            $strContent = ztagTransform($strContent, $strTransform);
        }
        $arrayTag[$tagId][ztagResult] = "<b>{$strContent}</b>";
    }
    if ($strValue) {
        if ($strTransform) {
            $strValue = ztagTransform($strValue, $strTransform);
        }
        $arrayTag[$tagId][ztagResult] = "<u>{$strValue}</u>";
    }
    if ($strVar) {
        if ($strTransform) {
            $strVar = ztagTransform($strVar, $strTransform);
        }
        $arrayTag[$tagId][ztagResult] = "<i>{$strVar}</i>";
    } else {
        if (!$strContent && !$strValue) {
            $errorMessage .= ztagParamCheck($arrParam, "value");
        }
    }
}
示例#11
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zmerlim_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zmerlim_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strURL = $arrParam["url"];
    $strVar = $arrParam["var"];
    $strUse = $arrParam["use"];
    $strValue = $arrParam["value"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * <zmerlim:read url="http://www.direito2.com.br" var="urlVar" errorno="errornoVar" error="errorVar" />
         *
         * Read a HTML from a URL with CURL
         *
         * url="http://www.direito2.com.br" URL to be retrieve
         * var="urlVar" var where the result will be saved
         */
        case "read":
            $errorMessage .= ztagParamCheck($arrParam, "url,var");
            $objCURL = curl_init();
            curl_setopt($objCURL, CURLOPT_URL, $strURL);
            curl_setopt($objCURL, CURLOPT_RETURNTRANSFER, 1);
            // curl_setopt($objCURL, CURLOPT_NOBODY, 1);
            curl_setopt($objCURL, CURLOPT_HEADER, 0);
            curl_setopt($objCURL, CURLOPT_CONNECTTIMEOUT, 10);
            curl_setopt($objCURL, CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($objCURL, CURLOPT_MAXREDIRS, 10);
            curl_setopt($objCURL, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)");
            // curl_setopt($objCURL, CURLOPT_COOKIE, "ASPSESSIONIDCSCARQCD=GHEFGIDCHDCLEEMGAKPEKPPO; __utma=15381288.711762829.1282791344.1282791344.1282791344.1; __utmb=15381288.8.10.1282791344; __utmc=15381288; __utmz=15381288.1282791344.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)" );
            $strResult = curl_exec($objCURL);
            if (curl_errno($objCURL)) {
                $strErrorNo = $arrParam["errorno"];
                $strError = $arrParam["error"];
                $errorMessage .= "<br /><b>Curl error</b>: " . curl_errno($objCURL) . " - " . curl_error($objCURL);
                if (strlen($strErrorNo)) {
                    $arrayTagId["\$" . $strErrorNo][ztagIdValue] = curl_errno($objCURL);
                    $arrayTagId["\$" . $strErrorNo][ztagIdLength] = 0;
                    $arrayTagId["\$" . $strErrorNo][ztagIdType] = idTypeFVar;
                }
                if (strlen($strError)) {
                    $arrayTagId["\$" . $strError][ztagIdValue] = curl_error($objCURL);
                    $arrayTagId["\$" . $strError][ztagIdLength] = strlen($strResult);
                    $arrayTagId["\$" . $strError][ztagIdType] = idTypeFVar;
                }
            }
            if (strlen($strVar) && strlen($strResult)) {
                $arrayTagId["\$" . $strVar][ztagIdValue] = $strResult;
                $arrayTagId["\$" . $strVar][ztagIdLength] = strlen($strResult);
                $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
            }
            // $arrcURL = curl_getinfo($objCURL);
            // echo "<br />http_code=".$arrcURL["http_code"];
            // echo "<br />content_type=".$arrcURL["content_type"];
            // if (isUTF8($strResult)) $strResult = utf8_decode($strResult);
            curl_close($objCURL);
            break;
            /*+
             * <zmerlim:tidy use="htmlVar" />
             *
             * Read a HTML from a URL with CURL
             *
             * url="http://www.direito2.com.br" URL to be retrieve
             * var="urlVar" var where the result will be saved
             */
        /*+
         * <zmerlim:tidy use="htmlVar" />
         *
         * Read a HTML from a URL with CURL
         *
         * url="http://www.direito2.com.br" URL to be retrieve
         * var="urlVar" var where the result will be saved
         */
        case "tidy":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            $arrOptions = array("drop-proprietary-attributes" => true, "drop-font-tags" => true, "drop-empty-paras" => true, "fix-backslash" => true, "hide-comments" => true, "join-classes" => true, "join-styles" => true, "word-2000" => true, "output-xhtml" => true, "clean" => true, "indent" => false, "indent-spaces" => 0, "logical-emphasis" => true, "lower-literals" => true, "quote-ampersand" => true, "quote-marks" => true, "quote-nbsp" => true, "wrap" => 0, "show-body-only" => true, "merge-divs" => "auto", "merge-spans" => "auto");
            // ascii-chars
            // utf8
            if ($strUse) {
                $strContent = $arrayTagId["\$" . $strUse][ztagIdValue];
            }
            $objTidy = tidy_parse_string($strContent, $arrOptions);
            $objTidy->cleanRepair();
            $strResult = str_replace("\r\n", "", $objTidy);
            if (strlen($strUse) && strlen($strResult)) {
                $arrayTagId["\$" . $strUse][ztagIdValue] = $strResult;
                $arrayTagId["\$" . $strUse][ztagIdLength] = count($strResult);
                $arrayTagId["\$" . $strUse][ztagIdType] = idTypeFVar;
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    /*
      debugError("tagFunction=$tagFunction"
    ."<br />tagId=$tagId"
    ."<br />strId=$strId"
    ."<br />strUse=$strUse"
    ."<br />strValue=$strValue"
    ."<br />arrayTagId[$strId][ztagIdValue]=".$arrayTagId[$strId][ztagIdValue]
    ."<br />arrayTagId[$strUse][ztagIdValue]=".$arrayTagId[$strUse][ztagIdValue]
    ."<br />arrayTag[$tagId][ztagResult]=".$arrayTag[$tagId][ztagResult]);
    */
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#12
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zout_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zout_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strURL = $arrParam["url"];
    $strVar = $arrParam["var"];
    $strUse = $arrParam["use"];
    $strValue = $arrParam["value"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Turn on output buffering
         *
         * <code>
         * <zout:start />
         * </code>
         */
        case "start":
            ob_start();
            break;
            /*+
             * Flush (send) the output buffer
             *
             * <code>
             * <zout:flush end="true" var="outVar" />
             * </code>
             *
             * @param boolean end="1|0|true|false" Define if will end the buffer
             * @param string var="outVar"
             */
        /*+
         * Flush (send) the output buffer
         *
         * <code>
         * <zout:flush end="true" var="outVar" />
         * </code>
         *
         * @param boolean end="1|0|true|false" Define if will end the buffer
         * @param string var="outVar"
         */
        case "flush":
            $strEnd = $arrParam["end"];
            if (strlen($strVar)) {
                $getValue = ob_get_flush();
                $arrayTagId["\$" . $strVar][ztagIdValue] = $getValue;
                $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
            } else {
                if ($strEnd == "true" || $strEnd == "1") {
                    ob_end_flush();
                } else {
                    ob_flush();
                }
            }
            break;
            /*+
             * Clean (erase) the output buffer
             *
             * <code>
             * <zout:clean end="true" />
             * </code>
             *
             * @param string end="1|0|true|false" Define if will end the buffer
             */
        /*+
         * Clean (erase) the output buffer
         *
         * <code>
         * <zout:clean end="true" />
         * </code>
         *
         * @param string end="1|0|true|false" Define if will end the buffer
         */
        case "clean":
            $strEnd = $arrParam["end"];
            if ($strEnd == "true" || $strEnd == "1") {
                ob_end_clean();
            } else {
                ob_clean();
            }
            break;
            /*+
             * Return the contents of the output buffer
             *
             * <code>
             * <zout:get var="outVar" clean="true" />
             * </code>
             *
             * @param boolean clean="1|0|true|false" Clear buffer after get it's content
             * @param string var="ourVar" Variable where the buffer's content will be saved
             */
        /*+
         * Return the contents of the output buffer
         *
         * <code>
         * <zout:get var="outVar" clean="true" />
         * </code>
         *
         * @param boolean clean="1|0|true|false" Clear buffer after get it's content
         * @param string var="ourVar" Variable where the buffer's content will be saved
         */
        case "get":
            $errorMessage .= ztagParamCheck($arrParam, "var");
            $strClean = $arrParam["clean"];
            if ($strClean == "true" || $strClean == "1") {
                $getValue = ob_get_clean();
            } else {
                $getValue = ob_get_contents();
            }
            echo "<br />getValue=" . strlen($getValue);
            echo "<br />getValue=" . strlen($getValue);
            if (strlen($strVar) && $getValue) {
                $arrayTagId["\$" . $strVar][ztagIdValue] = $getValue;
                $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
            }
            break;
            /*+
             * Return the length of the output buffer
             *
             * <code>
             * <zout:len var="outVar" />
             * </code>
             *
             * @param string var="ourVar" Variable where the buffer's content will be saved
             */
        /*+
         * Return the length of the output buffer
         *
         * <code>
         * <zout:len var="outVar" />
         * </code>
         *
         * @param string var="ourVar" Variable where the buffer's content will be saved
         */
        case "len":
            /*+
             * Return the length of the output buffer
             *
             * <code>
             * <zout:lenght var="outVar" />
             * </code>
             *
             * @param string var="ourVar" Variable where the buffer's content will be saved
             */
        /*+
         * Return the length of the output buffer
         *
         * <code>
         * <zout:lenght var="outVar" />
         * </code>
         *
         * @param string var="ourVar" Variable where the buffer's content will be saved
         */
        case "lenght":
            $errorMessage .= ztagParamCheck($arrParam, "var");
            $getValue = ob_get_length();
            if (strlen($strVar) && $getValue) {
                $arrayTagId["\$" . $strVar][ztagIdValue] = $getValue;
                $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#13
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zcode_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zcode_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strValue = $arrParam["value"];
    $strVar = $arrParam["var"];
    $strTransform = $arrParam["transform"];
    $strTitle = $arrParam["title"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Present in a code way of values content
         *
         *
         * Return the variable content in a formated code
         * Teste line
         *
         *
         * <code>
         * <zcode:show value="$templateValue" title="$templateFile" />
         * </code>
         *
         * @param string value="$templateValue"
         * @param string title="$templateFile"
         *
         * @param string dir="string" Full directory where the zTag .inc.php files are
         *
         * @return array Return an array with all docs and functions
         *
         * @since 0.0.2 ALFA
         *
         * @see zctrl:if
         *
         * @uses zvar:set
         *
         * @copyright 2010 by Ruben Zevallos(r) Jr.
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "show":
            // echo "<pre>".print_r($arrayTag[$tagId], 1)."</pre>";
            if ($strContent) {
                $contentHTML = $strContent;
            }
            if ($strValue) {
                $contentHTML = $strValue;
            }
            if ($strVar) {
                $contentHTML = $strVar;
            } else {
                if (!$strContent && !$strValue) {
                    $errorMessage .= ztagParamCheck($arrParam, "value");
                }
            }
            if ($strTransform) {
                $contentHTML = ztagTransform($contentHTML, $strTransform);
            }
            $contentHTML = preg_replace("/\t/", "  ", $contentHTML);
            $contentHTML = ltrim($contentHTML, "\r\n");
            $contentHTML = rtrim($contentHTML, "\r\n");
            preg_match_all("%^(?P<spaces>[ ]+)?(?P<line>.*?)(\r)?(\n)%sm", $contentHTML . "\r\n", $Matches, PREG_OFFSET_CAPTURE);
            $contentHTML = "";
            $lineMax = 0;
            $lineMin = 9999;
            foreach ($Matches[0] as $key => $value) {
                if (strlen($Matches["line"][$key][0]) > 0 && $lineMax < ($intSize = strlen($Matches["spaces"][$key][0]))) {
                    $lineMax = $intSize;
                }
                if (strlen($Matches["line"][$key][0]) > 0 && $lineMin > ($intSize = strlen($Matches["spaces"][$key][0]))) {
                    $lineMin = $intSize;
                }
            }
            foreach ($Matches[0] as $key => $value) {
                $lineSpaces = $Matches["spaces"][$key][0];
                $lineSpaces = substr($lineSpaces, $lineMin, strlen($lineSpaces));
                $lineContent = $Matches["line"][$key][0];
                if (!$lineAlt) {
                    $lineAlt = " class=\"alt\"";
                } else {
                    $lineAlt = "";
                }
                $contentHTML .= "<li{$lineAlt}>" . preg_replace("/\\s/", "&nbsp;", $lineSpaces) . htmlentities($lineContent) . "</li>";
                $contentPRE .= $lineSpaces . $lineContent . "\n";
            }
            /*
                        ."<div class=\"bar\">"
                        ."<div class=\"tools\"><a onclick=\"zcodeViewPlain('ViewSource',this);return false;\" href=\"#\">view plain</a>"
                        ."<a onclick=\"zcodeViewSource(this);return false;\" href=\"#\">copy to clipboard</a>"
                        ."<a onclick=\"zcodePrintSource('PrintSource',this);return false;\" href=\"#\">print</a>"
                        ."<a onclick=\"zcodeAbout('About',this);return false;\" href=\"#\">?</a>"
                        ."</div>"
                        ."</div>"
            */
            $html = "<div style=\"border-width: 1px;\">" . "<div style=\"border-bottom-width: 1px;\" class=\"codeHeader panelHeader\"><b>\"{$strTitle}\"</b></div>" . "<div>" . "<div class=\"zcode\">" . "<ol start=\"1\" class=\"dp-c\">" . $contentHTML . "</ol>" . "</div>" . "<pre style=\"display: none;\">" . $contentPRE . "</pre>" . "</div>" . "</div>";
            $arrayTag[$tagId][ztagResult] = $html;
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#14
0
function zhtml_cellhead($tagId, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strTagId = $arrParam["tagid"];
    $strValue = $arrParam["value"];
    $strTransform = $arrParam["transform"];
    $strContent = $arrayTag[$tagId][ztagContent];
    if (strlen($strValue)) {
        $strContent = $strValue;
    }
    $arrParam["value"] = $strContent;
    if (!$strTagId) {
        $strTagId = $strName;
    }
    $arrParam["id"] = $strTagId;
    $strTag = "th";
    $strParam = ztagParam($arrParam, "alt,align,border,height,width,id,class,style,nowrap,colspan");
    $errorMessage = ztagParamCheck($arrParam, "value");
    if ($strTransform) {
        $strContent = ztagTransform($strContent, $strTransform);
    }
    $arrayTag[$tagId][ztagResult] = "<{$strTag}{$strParam}>{$strContent}</{$strTag}>";
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#15
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zvar_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zvar_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $strUse = $arrParam["use"];
    $strVar = $arrParam["var"];
    $strValue = $arrParam["value"];
    $strTransform = $arrParam["transform"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Creates a $var with it's value
         *
         * <code>
         * <zvar:set id="someVar" value="someValue" />
         *
         * <zvar:set id="otherVar">
         *   It's value
         * </zvar:set>
         * </code>
         *
         * @param string id="someVar" Unique Id for the new variable $varName
         * @param string value="someValue" Value to b saved into this variable
         */
        case "set":
            if ($arrayTag[$tagId][ztagContentWidth]) {
                $strValue = ztagVars($arrayTag[$tagId][ztagContent], $arrayTagId);
                $arrParam["value"] = $strValue;
            }
            if (strlen($strVar)) {
                $strId = $strVar;
                $arrParam["id"] = $strId;
            }
            $errorMessage .= ztagParamCheck($arrParam, "value,id");
            if (strlen($strTransform)) {
                $strValue = ztagTransform($strValue, $strTransform);
            }
            $arrayTagId["\$" . $strId][ztagIdValue] = $strValue;
            $arrayTagId["\$" . $strId][ztagIdLength] = strlen($strValue);
            $arrayTagId["\$" . $strId][ztagIdType] = idTypeFVar;
            break;
            /*+
             * Creates an array var $someArray with it´s formated content
             *
             * <code>
             * <zvar:setarray id="someArray">
             *   "index"="value"
             *   , "index2":"value 2"
             *   , 'index3'=>'value 3'
             *   , 99="value"
             *   , "indexn"=99
             * </znosql:setarray>
             *
             * <zvar:setarray id="someArray" value="'index'='value',9='value'" />
             * </code>
             *
             * @param string id="someArray" Unique Id for the new variable $varName
             */
        /*+
         * Creates an array var $someArray with it´s formated content
         *
         * <code>
         * <zvar:setarray id="someArray">
         *   "index"="value"
         *   , "index2":"value 2"
         *   , 'index3'=>'value 3'
         *   , 99="value"
         *   , "indexn"=99
         * </znosql:setarray>
         *
         * <zvar:setarray id="someArray" value="'index'='value',9='value'" />
         * </code>
         *
         * @param string id="someArray" Unique Id for the new variable $varName
         */
        case "setarray":
            if (strlen($strContent)) {
                $contentArray = $strContent;
            }
            if (strlen($strValue)) {
                $contentArray = $strValue;
            }
            if ($contentArray) {
                $contentArray = ztagVars($contentArray, $arrayTagId);
                $arrParam["value"] = $strValue;
            }
            if (!strlen($strContent) && !strlen($strValue)) {
                $errorMessage .= ztagParamCheck($arrParam, "id,value");
            }
            if ($strTransform && $contentArray) {
                $contentArray = ztagTransform($contentArray, $strTransform);
            }
            $contentArray = ltrim($contentArray, "\r\n");
            $contentArray = rtrim($contentArray, "\r\n");
            preg_match_all('%\\s*,?\\s*(?P<index>"[^"]*?"|\'[^\']*?\'|\\d+)\\s*(:|=|=>)\\s*(?P<value>"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|\\d+)%', $contentArray, $Matches, PREG_OFFSET_CAPTURE);
            $arrayContent = array();
            foreach ($Matches[0] as $key => $value) {
                $paramKey = $Matches["index"][$key][0];
                $paramValue = $Matches["value"][$key][0];
                $patternString = '%^(["\'])(.*?)\\1%';
                $paramKey = preg_replace($patternString, "\$2", $paramKey);
                $paramValue = preg_replace($patternString, "\$2", $paramValue);
                $arrayContent[$paramKey] = preg_replace('%\\\\([\'"])%', "\$1", $paramValue);
            }
            $arrayTagId["\$" . $strId][ztagIdValue] = $arrayContent;
            $arrayTagId["\$" . $strId][ztagIdLength] = count($arrayContent);
            $arrayTagId["\$" . $strId][ztagIdType] = idTypeFVar;
            break;
            /*+
             * Creates a $var if the contidion is made with it´s value
             *
             * <code>
             * <zvar:setif use="getFiltro" equal="nome" var="sqlSelect" then="(SELECT CD_PESSOA FROM TB_ENDERECO_PESSOA WHERE NM_PESSOA LIKE '%$getFiltro%')" />
             *
             * <zvar:setif use="CO_CPF" condition="empty()" var="sqlSelect" then="CO_CPF LIKE '%$CO_CPF%'" />
             * </code>
             *
             * @param string use="getFiltro"
             * @param string equal="nome"
             * @param string var="sqlSelect"
             * @param string then="(SELECT CD_PESSOA FROM TB_ENDERECO_PESSOA WHERE NM_PESSOA LIKE '%$getFiltro%')"
             */
        /*+
         * Creates a $var if the contidion is made with it´s value
         *
         * <code>
         * <zvar:setif use="getFiltro" equal="nome" var="sqlSelect" then="(SELECT CD_PESSOA FROM TB_ENDERECO_PESSOA WHERE NM_PESSOA LIKE '%$getFiltro%')" />
         *
         * <zvar:setif use="CO_CPF" condition="empty()" var="sqlSelect" then="CO_CPF LIKE '%$CO_CPF%'" />
         * </code>
         *
         * @param string use="getFiltro"
         * @param string equal="nome"
         * @param string var="sqlSelect"
         * @param string then="(SELECT CD_PESSOA FROM TB_ENDERECO_PESSOA WHERE NM_PESSOA LIKE '%$getFiltro%')"
         */
        case "setif":
            $strEqual = $arrParam["equal"];
            $strNotEqual = $arrParam["notequal"];
            $strThen = $arrParam["then"];
            $strElse = $arrParam["else"];
            $strCondition = $arrParam["condition"];
            $strNotCondition = $arrParam["notcondition"];
            $errorMessage .= ztagParamCheck($arrParam, "use,then,var");
            if ($strUse) {
                $strUse = $arrayTagId["\$" . $strUse][ztagIdValue];
            }
            if ($strEqual) {
                if ($strUse == $strEqual) {
                    $arrayTagId["\$" . $strVar][ztagIdValue] = $strThen;
                } else {
                    if ($strElse) {
                        $arrayTagId["\$" . $strVar][ztagIdValue] = $strElse;
                    }
                }
            }
            if ($strNotEqual) {
                if ($strUse != $strNotEqual) {
                    $arrayTagId["\$" . $strVar][ztagIdValue] = $strThen;
                } else {
                    if ($strElse) {
                        $arrayTagId["\$" . $strVar][ztagIdValue] = $strElse;
                    }
                }
            }
            if ($strCondition) {
                $strCondition = ztagTransform($strUse, $strCondition);
                if ($strCondition) {
                    $arrayTagId["\$" . $strVar][ztagIdValue] = $strThen;
                } else {
                    if ($strElse) {
                        $arrayTagId["\$" . $strVar][ztagIdValue] = $strElse;
                    }
                }
            }
            if ($strNotCondition) {
                $strNotCondition = ztagTransform($strUse, $strNotCondition);
                if (!$strNotCondition) {
                    $arrayTagId["\$" . $strVar][ztagIdValue] = $strThen;
                } else {
                    if ($strElse) {
                        $arrayTagId["\$" . $strVar][ztagIdValue] = $strElse;
                    }
                }
            }
            break;
            /*+
             * Unset a variable
             *
             * <code>
             * <zvar:unset use="getFiltro" />
             * </code>
             *
             * @param string use="getFiltro"
             */
        /*+
         * Unset a variable
         *
         * <code>
         * <zvar:unset use="getFiltro" />
         * </code>
         *
         * @param string use="getFiltro"
         */
        case "unset":
            /*+
             * Reset a variable
             *
             * <code>
             * <zvar:reset use="getFiltro" />
             * </code>
             *
             * @param string use="getFiltro"
             */
        /*+
         * Reset a variable
         *
         * <code>
         * <zvar:reset use="getFiltro" />
         * </code>
         *
         * @param string use="getFiltro"
         */
        case "reset":
            $errorMessage = ztagParamCheck($arrParam, "use");
            if ($arrayTagId["\$" . $strUse][ztagIdType] != idTypeFVar) {
                $errorMessage .= "<br />The handle \"{$strUse}\" is not a var one!";
            }
            $arrayTagId["\$" . $strUse] = array();
            break;
            /*+
             * Update a $var with it's value
             *
             * <code>
             * <zvar:update use="someVar" value="someValue" />
             *
             * <zvar:set use="otherVar">
             *   It's value
             * </zvar:set>
             * </code>
             *
             * @param string use="someVar" Unique Id of a variable $varName
             * @param string value="someValue" Value to b saved into this variable
             */
        /*+
         * Update a $var with it's value
         *
         * <code>
         * <zvar:update use="someVar" value="someValue" />
         *
         * <zvar:set use="otherVar">
         *   It's value
         * </zvar:set>
         * </code>
         *
         * @param string use="someVar" Unique Id of a variable $varName
         * @param string value="someValue" Value to b saved into this variable
         */
        case "update":
            if ($arrayTag[$tagId][ztagContentWidth]) {
                $strValue = ztagVars($arrayTag[$tagId][ztagContent], $arrayTagId);
                $arrParam["value"] = $strValue;
            }
            $errorMessage .= ztagParamCheck($arrParam, "value,use");
            if (strlen($strUse)) {
                $arrayTagId["\$" . $strUse][ztagIdValue] = $strValue;
                $arrayTagId["\$" . $strUse][ztagIdLength] = strlen($strValue);
                $arrayTagId["\$" . $strUse][ztagIdType] = idTypeFVar;
            }
            break;
            /*+
             * Get and return a variable value
             *
             * <code>
             * <zvar:get use="getFiltro" />
             * </code>
             *
             * @param string use="getFiltro"
             */
        /*+
         * Get and return a variable value
         *
         * <code>
         * <zvar:get use="getFiltro" />
         * </code>
         *
         * @param string use="getFiltro"
         */
        case "get":
            /*+
             * Show variable value
             *
             * <code>
             * <zvar:show use="getFiltro" />
             * </code>
             *
             * @param string use="getFiltro"
             */
        /*+
         * Show variable value
         *
         * <code>
         * <zvar:show use="getFiltro" />
         * </code>
         *
         * @param string use="getFiltro"
         */
        case "show":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            preg_match_all('%^(?P<var>\\w+)\\[(?P<index>[^\\]]+)\\]$%', $strUse, $Matches, PREG_OFFSET_CAPTURE);
            if (count($Matches[0][0])) {
                $var = $Matches["var"][0][0];
                $index = $Matches["index"][0][0];
                $varValue = $arrayTagId["\$" . $var][ztagIdValue];
                $varValue = $varValue[$index];
            } else {
                if ($arrayTagId["\$" . $strUse][ztagIdType] != idTypeFVar) {
                    $errorMessage .= "<br />The handle \"{$strUse}\" is not a var one!";
                }
                $varValue = $arrayTagId["\$" . $strUse][ztagIdValue];
            }
            if (strlen($strTransform)) {
                $varValue = ztagTransform($varValue, $strTransform);
            }
            $arrayTag[$tagId][ztagResult] = $varValue;
            break;
            /*+
             * Creates a $arrayVar for var parameters, applying the pattern using use var content.
             *
             * <code>
             * <zvar:regex pattern='%title="(?P<title>.*?)" href="(?P<url>/\d+/\d+_\w+/(?P<id>\d+)/[\w-]+.htm)%' use="urlAssunto" var="arrayAssunto" />
             * </code>
             *
             * @param string pattern='%title="(?P<title>.*?)" href="(?P<url>/\d+/\d+_\w+/(?P<id>\d+)/[\w-]+.htm)%'
             * @param string use="urlAssunto"
             * @param string value="$arrayValue"
             * @param string var="arrayAssunto"
             * @param string error="errorVar"
             */
        /*+
         * Creates a $arrayVar for var parameters, applying the pattern using use var content.
         *
         * <code>
         * <zvar:regex pattern='%title="(?P<title>.*?)" href="(?P<url>/\d+/\d+_\w+/(?P<id>\d+)/[\w-]+.htm)%' use="urlAssunto" var="arrayAssunto" />
         * </code>
         *
         * @param string pattern='%title="(?P<title>.*?)" href="(?P<url>/\d+/\d+_\w+/(?P<id>\d+)/[\w-]+.htm)%'
         * @param string use="urlAssunto"
         * @param string value="$arrayValue"
         * @param string var="arrayAssunto"
         * @param string error="errorVar"
         */
        case "regex":
            $strPattern = $arrParam["pattern"];
            $strError = $arrParam["error"];
            $errorMessage .= ztagParamCheck($arrParam, "pattern,var");
            if ($strUse) {
                $strValue = $arrayTagId["\$" . $strUse][ztagIdValue];
            }
            preg_match_all($strPattern, $strValue, $Matches, PREG_SET_ORDER);
            $arrayResult = array();
            foreach ($Matches as $keyMatches => $valueMatches) {
                foreach ($valueMatches as $key => $value) {
                    if (is_string($key) || $key) {
                        $arrayMatches[$key] = $value;
                    }
                }
                $arrayResult[] = $arrayMatches;
            }
            if (preg_last_error() && strlen($strError)) {
                $arrayTagId["\$" . $strError][ztagIdValue] = preg_last_error();
                $arrayTagId["\$" . $strError][ztagIdLength] = count(preg_last_error());
                $arrayTagId["\$" . $strError][ztagIdType] = idTypeFVar;
            } else {
                $arrayTagId["\$" . $strError] = array();
            }
            if (strlen($strVar) && count($arrayResult)) {
                $arrayTagId["\$" . $strVar][ztagIdValue] = $arrayResult;
                $arrayTagId["\$" . $strVar][ztagIdLength] = count($arrayResult);
                $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
            } else {
                $arrayTagId["\$" . $strVar] = array();
            }
            break;
            /*+
             * Decrement a variable value
             *
             * <code>
             * <zvar:decrement use="getFiltro" />
             * </code>
             *
             * @param string use="getFiltro"
             */
        /*+
         * Decrement a variable value
         *
         * <code>
         * <zvar:decrement use="getFiltro" />
         * </code>
         *
         * @param string use="getFiltro"
         */
        case "decrement":
            /*+
             * Decrement a variable value
             *
             * <code>
             * <zvar:dec use="getFiltro" />
             * </code>
             *
             * @param string use="getFiltro"
             */
        /*+
         * Decrement a variable value
         *
         * <code>
         * <zvar:dec use="getFiltro" />
         * </code>
         *
         * @param string use="getFiltro"
         */
        case "dec":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            preg_match_all('%^(?P<var>\\w+)\\[(?P<index>[^\\]]+)\\]$%', $strUse, $Matches, PREG_OFFSET_CAPTURE);
            if (count($Matches[0][0])) {
                $var = $Matches["var"][0][0];
                $index = $Matches["index"][0][0];
                $varValue = $arrayTagId["\$" . $var][ztagIdValue];
                $arrayTagId["\$" . $var][ztagIdValue] = $varValue[$index]--;
            } else {
                if ($arrayTagId["\$" . $strUse][ztagIdType] != idTypeFVar) {
                    $errorMessage .= "<br />The handle \"{$strUse}\" is not a var one!";
                }
                $arrayTagId["\$" . $strUse][ztagIdValue]--;
            }
            break;
            /*+
             * Increment a variable value
             *
             * <code>
             * <zvar:increment use="getFiltro" />
             * </code>
             *
             * @param string use="getFiltro"
             */
        /*+
         * Increment a variable value
         *
         * <code>
         * <zvar:increment use="getFiltro" />
         * </code>
         *
         * @param string use="getFiltro"
         */
        case "increment":
            /*+
             * Increment a variable value
             *
             * <code>
             * <zvar:inc use="getFiltro" />
             * </code>
             *
             * @param string use="getFiltro"
             */
        /*+
         * Increment a variable value
         *
         * <code>
         * <zvar:inc use="getFiltro" />
         * </code>
         *
         * @param string use="getFiltro"
         */
        case "inc":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            preg_match_all('%^(?P<var>\\w+)\\[(?P<index>[^\\]]+)\\]$%', $strUse, $Matches, PREG_OFFSET_CAPTURE);
            if (count($Matches[0][0])) {
                $var = $Matches["var"][0][0];
                $index = $Matches["index"][0][0];
                $varValue = $arrayTagId["\$" . $var][ztagIdValue];
                $arrayTagId["\$" . $var][ztagIdValue] = $varValue[$index]++;
            } else {
                if ($arrayTagId["\$" . $strUse][ztagIdType] != idTypeFVar) {
                    $errorMessage .= "<br />The handle \"{$strUse}\" is not a var one!";
                }
                $arrayTagId["\$" . $strUse][ztagIdValue]++;
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#16
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zom_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zom_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        // <zdb:open id="mssqlD2" driver="mssql" host="#mssqlD2" user="******", password="******" />
        // <zdb:open id="mssqlALFA" driver="mssql" host="#mssqlALFA" user="******", password="******" />
        // <zom:copy source="Pass" destination="mssqlALFA" idsource="" iddestination="" />
        // <zdb:close id="mssqlD2" />
        // <zdb:close id="mssqlALFA" />
        case "copy":
            $strSource = $arrParam["source"];
            $strDestination = $arrParam["destination"];
            $strIdSource = $arrParam["idsource"];
            $strIdDestination = $arrParam["iddestination"];
            $errorMessage .= ztagParamCheck($arrParam, "source,destination,idsource,iddestination");
            $sql = "SELECT * FROM pubPaginas WHERE pagPai = {$strIdSource}";
            dbQuery($arrayTagId[$strSource][ztagIdHandle], $sql);
            while (dbFetch($arrayTagId[$strSource][ztagIdHandle])) {
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#17
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zform_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zform_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $strTagId = $arrParam["tagid"];
    $strName = $arrParam["name"];
    $strCaption = $arrParam["caption"];
    $strValue = $arrParam["value"];
    $strValues = $arrParam["values"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    if (!$strTagId) {
        $strTagId = $strName;
    }
    $arrParam["id"] = $strTagId;
    $arrParam["for"] = $strTagId;
    if ($strCaption) {
        if (strpos(" {$strCaption}", "&")) {
            $labelAccessKey = preg_match("%&(.)%i", $strCaption);
            if (!$labelAccessKey) {
                $labelAccessKey = substr($strCaption, 1, 1);
            }
            $arrParam["accesskey"] = $labelAccessKey;
            $strCaption = preg_replace("%^(.*)&(.)(.*)\$%i", "\$1<u>\$2</u>\$3", $strCaption);
        }
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Input Text
         *
         * <code>
         * <zform:input type="text" name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string type="text"
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "input":
            $errorMessage = ztagParamCheck($arrParam, "type,name");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly,disabled,autocomplete,maxlength,size,tabindex,datebr");
            $arrayTag[$tagId][ztagResult] = "<input{$strParam} />";
            break;
            /*+
             * Input Text
             *
             * <code>
             * <zform:inputtext name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Input Text
         *
         * <code>
         * <zform:inputtext name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "inputtext":
            $arrParam["type"] = "text";
            $errorMessage = ztagParamCheck($arrParam, "type,name");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly,disabled,autocomplete,maxlength,size,tabindex,title,datebr");
            $arrayTag[$tagId][ztagResult] = "<input{$strParam} />";
            break;
            /*+
             * Input Hidden
             *
             * <code>
             * <zform:inputhidden name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Input Hidden
         *
         * <code>
         * <zform:inputhidden name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "inputhidden":
            $arrParam["type"] = "hidden";
            $errorMessage = ztagParamCheck($arrParam, "type,name");
            $strParam = ztagParam($arrParam, "type,id,name,value");
            $arrayTag[$tagId][ztagResult] = "<input{$strParam} />";
            break;
            /*+
             * Input Password
             *
             * <code>
             * <zform:inputpassword name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Input Password
         *
         * <code>
         * <zform:inputpassword name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "inputpassword":
            $arrParam["type"] = "password";
            $errorMessage = ztagParamCheck($arrParam, "type,name");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly");
            $arrayTag[$tagId][ztagResult] = "<input{$strParam} />";
            break;
            /*+
             * Input Checkbox
             *
             * <code>
             * <zform:inputcheckbox name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Input Checkbox
         *
         * <code>
         * <zform:inputcheckbox name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "inputcheckbox":
            $arrParam["type"] = "checkbox";
            $arrValues = explode(";", $strValues);
            if ($arrValues[0] == $strValue) {
                $strChecked = " checked=\"checked\"";
            }
            $errorMessage = ztagParamCheck($arrParam, "type,name,values");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly");
            $arrayTag[$tagId][ztagResult] = "<input{$strParam}{$strChecked} />";
            break;
            /*+
             * Text Area
             *
             * <code>
             * <zform:textarea name="fieldName" tagid="fieldId" value="fieldValue" />
             *
             * <zform:textarea name="fieldName" tagid="fieldId" filename="fileSave.txt" filetype="txt">
             * Text Area value
             * </zform:textarea>
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @param string filename="/Alianca8/File.txt"
             * @param string filetype="txt"
             * @param string show="0"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Text Area
         *
         * <code>
         * <zform:textarea name="fieldName" tagid="fieldId" value="fieldValue" />
         *
         * <zform:textarea name="fieldName" tagid="fieldId" filename="fileSave.txt" filetype="txt">
         * Text Area value
         * </zform:textarea>
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @param string filename="/Alianca8/File.txt"
         * @param string filetype="txt"
         * @param string show="0"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "textarea":
            $strFileName = $arrParam["filename"];
            $strFileType = $arrParam["filetype"];
            $strShow = strtolower($arrParam["show"]);
            if (strlen($strContent)) {
                $arrParam["value"] = $strContent;
            }
            $strValue = $arrParam["value"];
            if (strlen($strValue)) {
                $strValue = ztagVars($strValue, $arrayTagId);
                $strValue = ztagRun($strValue, 0, $arrayTagId);
            }
            $arrParam["type"] = "textarea";
            $errorMessage = ztagParamCheck($arrParam, "type,name");
            $strParam = ztagParam($arrParam, "type,id,name,style,required,readonly,disabled,cols,rows,tabindex,title");
            $arrayTag[$tagId][ztagResult] = "<textarea{$strParam} />{$strValue}</textarea>";
            $blnShow = $strShow === "true" || $strShow === "1" || !strlen($strShow);
            if ($strFileName) {
                $strFileName = str_replace("\\", "/", $strFileName);
                if (substr($strFileName, 0, 1) === "/") {
                    $strFileName = substr($strFileName, 1);
                }
                $strFileName = SiteRootDir . $strFileName;
                if (!($handleFile = fopen($strFileName, "w"))) {
                    $errorMessage .= "\r\nCannot open file ({$strFileName})";
                }
            }
            if ($handleFile && fwrite($handleFile, $strValue) === FALSE) {
                if (!$errorMessageTemp) {
                    $errorMessage .= $errorMessageTemp = "\r\nCannot write to file ({$strFileName})";
                }
            }
            if ($handleFile) {
                fclose($handleFile);
            }
            break;
            /*+
             * Select
             *
             * <code>
             * <zform:select name="textNameSelect" tagid="textIdSelect" value="tagOptionValue1,tagOptionCaption1;tagOptionValue2,tagOptionCaption2;tagOptionValue3,tagOptionCaption3" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Select
         *
         * <code>
         * <zform:select name="textNameSelect" tagid="textIdSelect" value="tagOptionValue1,tagOptionCaption1;tagOptionValue2,tagOptionCaption2;tagOptionValue3,tagOptionCaption3" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "select":
            $strOptions = $arrParam["options"];
            if ($strOptions) {
                $arrOptions = explode(";", $strOptions);
                foreach ($arrOptions as $keyOptions => $valueOptions) {
                    $strSelected = "";
                    $arrOption = explode(",", $valueOptions);
                    if ($strValue == $arrOption[0]) {
                        $strSelected = " selected=\"selected\"";
                    }
                    if (!$arrOption[1]) {
                        $arrOption[1] = $arrOption[0];
                    }
                    $strOptions .= "<option value=\"{$arrOption['0']}\"{$strSelected}>{$arrOption['1']}</option>";
                }
            }
            $errorMessage = ztagParamCheck($arrParam, "name,options");
            $strParam = ztagParam($arrParam, "type,id,name,style,required,readonly,disabled,cols,rows,tabindex,title");
            $arrayTag[$tagId][ztagResult] = "<select{$strParam} />{$strOptions}</select>";
            break;
            /*+
             * Input Submit
             *
             * <code>
             * <zform:inputsubmit name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Input Submit
         *
         * <code>
         * <zform:inputsubmit name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "inputsubmit":
            $arrParam["type"] = "submit";
            $errorMessage = ztagParamCheck($arrParam, "type,name,value");
            $strParam = ztagParam($arrParam, "type,id,name,value");
            $arrayTag[$tagId][ztagResult] = "<input{$strParam} />";
            break;
            /*+
             * Box
             *
             * <code>
             * <zform:box type="text" caption="caption" name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Box
         *
         * <code>
         * <zform:box type="text" caption="caption" name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "box":
            $errorMessage = ztagParamCheck($arrParam, "type,caption,name");
            $strLabel = ztagParam($arrParam, "accesskey,for");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly,disabled,autocomplete,maxlength,size,tabindex,title,datebr");
            $arrayTag[$tagId][ztagResult] = "<label{$strLabel}>{$strCaption}<br /><input{$strParam} /></label>";
            break;
            /*+
             * Box Text
             *
             * <code>
             * <zform:boxtext caption="caption" name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Box Text
         *
         * <code>
         * <zform:boxtext caption="caption" name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "boxtext":
            $arrParam["type"] = "text";
            $errorMessage = ztagParamCheck($arrParam, "type,caption,name");
            $strLabel = ztagParam($arrParam, "accesskey,for");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly,disabled,autocomplete,maxlength,size,tabindex,title,datebr");
            $arrayTag[$tagId][ztagResult] = "<label{$strLabel}>{$strCaption}<br /><input{$strParam} /></label>";
            break;
            /*+
             * Box Password
             *
             * <code>
             * <zform:boxpassword name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Box Password
         *
         * <code>
         * <zform:boxpassword name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "boxpassword":
            $arrParam["type"] = "password";
            $errorMessage = ztagParamCheck($arrParam, "type,caption,name");
            $strLabel = ztagParam($arrParam, "accesskey,for");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly");
            $arrayTag[$tagId][ztagResult] = "<label{$strLabel}>{$strCaption}<br /><input{$strParam} /></label>";
            break;
            /*+
             * Box Checkbox
             *
             * <code>
             * <zform:boxcheckbox caption="&CheckBox" name="checkboxNameBox" tagid="checkboxIdBox"  value="checkboxValueOn" values="checkboxValueOn;checkboxValueOff" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Box Checkbox
         *
         * <code>
         * <zform:boxcheckbox caption="&CheckBox" name="checkboxNameBox" tagid="checkboxIdBox"  value="checkboxValueOn" values="checkboxValueOn;checkboxValueOff" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "boxcheckbox":
            $arrParam["type"] = "checkbox";
            $arrValues = explode(";", $strValues);
            if ($arrValues[0] == $strValue) {
                $arrParam["checked"] = "checked";
            }
            $errorMessage = ztagParamCheck($arrParam, "type,name,value,values");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly");
            $arrayTag[$tagId][ztagResult] = "<label{$strLabel}><input{$strParam} /> {$strCaption}</label>";
            break;
            /*+
             * Box Radio
             *
             * <code>
             * <zform:boxradio caption="Processos com GTOs duplicadas" name="FL_CONTA_MEDICA_Estado" tagid="FL_DATA_Consulta" value="1" checked="$FL_GTO_DUPLICADACheck" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Box Radio
         *
         * <code>
         * <zform:boxradio caption="Processos com GTOs duplicadas" name="FL_CONTA_MEDICA_Estado" tagid="FL_DATA_Consulta" value="1" checked="$FL_GTO_DUPLICADACheck" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "boxradio":
            $arrParam["type"] = "radio";
            $arrValues = explode(";", $strValues);
            if ($arrValues[0] == $strValue) {
                $arrParam["checked"] = "checked";
            }
            $errorMessage = ztagParamCheck($arrParam, "type,name,value,values");
            $strParam = ztagParam($arrParam, "type,id,name,value,style,required,readonly");
            $arrayTag[$tagId][ztagResult] = "<label{$strLabel}><input{$strParam} /> {$strCaption}</label>";
            break;
            /*+
             * Box Text Area
             *
             * <code>
             * <zform:boxtextarea name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Box Text Area
         *
         * <code>
         * <zform:boxtextarea name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "boxtextarea":
            $arrParam["type"] = "textarea";
            $errorMessage = ztagParamCheck($arrParam, "type,caption,name,value");
            $strLabel = ztagParam($arrParam, "accesskey,for");
            $strParam = ztagParam($arrParam, "type,id,name,style,required,readonly,disabled,cols,rows,tabindex,title");
            $arrayTag[$tagId][ztagResult] = "<label{$strLabel}>{$strCaption}<br /><textarea{$strParam} />{$strValue}</textarea></label>";
            break;
            /*+
             * Box Select
             *
             * <code>
             * <zform:boxselect caption="&Text" name="textNameBox" tagid="textIdBox" value="textValueBox" options="tagOptionValue1,tagOptionCaption1;tagOptionValue2,tagOptionCaption2;tagOptionValue3,tagOptionCaption3" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Box Select
         *
         * <code>
         * <zform:boxselect caption="&Text" name="textNameBox" tagid="textIdBox" value="textValueBox" options="tagOptionValue1,tagOptionCaption1;tagOptionValue2,tagOptionCaption2;tagOptionValue3,tagOptionCaption3" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "boxselect":
            $strOptions = $arrParam["options"];
            if ($strOptions) {
                $arrOptions = explode(";", $strOptions);
                $strOptions = "";
                foreach ($arrOptions as $keyOptions => $valueOptions) {
                    $strSelected = "";
                    $arrOption = explode(",", $valueOptions);
                    if ($strValue == $arrOption[0]) {
                        $strSelected = " selected=\"selected\"";
                    }
                    if (!$arrOption[1]) {
                        $arrOption[1] = $arrOption[0];
                    }
                    $strOptions .= "<option value=\"{$arrOption['0']}\"{$strSelected}>{$arrOption['1']}</option>";
                }
            }
            $errorMessage = ztagParamCheck($arrParam, "name,options");
            $strLabel = ztagParam($arrParam, "accesskey,for");
            $strParam = ztagParam($arrParam, "type,id,name,style,required,readonly,disabled,cols,rows,tabindex,title");
            $arrayTag[$tagId][ztagResult] = "<label{$strLabel}>{$strCaption}<br /><select{$strParam} />{$strOptions}</select></label>";
            break;
            /*+
             * Button
             *
             * <code>
             * <zform:button name="fieldName" tagid="fieldId" value="fieldValue" />
             * </code>
             *
             * @param string name="fieldName"
             * @param string tagid="fieldId"
             * @param string value="fieldValue"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Button
         *
         * <code>
         * <zform:button name="fieldName" tagid="fieldId" value="fieldValue" />
         * </code>
         *
         * @param string name="fieldName"
         * @param string tagid="fieldId"
         * @param string value="fieldValue"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "button":
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#18
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zpost_zexecute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zpost_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strName = $arrParam["name"];
    $strVar = $arrParam["var"];
    $strTransform = $arrParam["transform"];
    if ($strName) {
        $strPostValue = $_POST[$strName];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Get
         *
         * <code>
         * <zdoc:get name="string" var="string" />
         * </code>
         *
         * @param name="string"
         * @param var="string"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "get":
            $errorMessage .= ztagParamCheck($arrParam, "name,var");
            if ($strTransform) {
                $strPostValue = ztagTransform($strPostValue, $strTransform);
            }
            if ($strVar) {
                $arrayTagId["\$" . $strVar][ztagIdValue] = $strPostValue;
                $arrayTagId["\$" . $strVar][ztagIdType] = idTypePost;
            }
            if (isset($strPostValue)) {
                $arrayTag[$tagId][ztagValue] = $strPostValue;
            }
            break;
            /*+
             * Show
             *
             * <code>
             * <zdoc:show name="string" />
             * </code>
             *
             * @param name="string"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Show
         *
         * <code>
         * <zdoc:show name="string" />
         * </code>
         *
         * @param name="string"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "show":
            $errorMessage = ztagParamCheck($arrParam, "name");
            if ($strTransform) {
                $strPostValue = ztagTransform($strPostValue, $strTransform);
            }
            if (isset($strPostValue)) {
                $arrayTag[$tagId][ztagResult] = $strPostValue;
            }
            break;
        default:
            $strMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#19
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zsession_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zsession_zexecute($tagId, $tagFunction, &$arrayTag, $arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strName = $arrParam["name"];
    $strValue = $arrParam["value"];
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Set
         *
         * <code>
         * <zsession:set name="string" value="value" />
         * </code>
         *
         * @param string name="string"
         * @param string value="value"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "set":
            $errorMessage .= ztagParamCheck($arrParam, "name,value");
            if (strlen($strValue)) {
                $_SESSION[$strName] = $strValue;
            }
            break;
            /*+
             * Get
             *
             * <code>
             * <zdoc:get name="string" />
             * </code>
             *
             * @param string name="string"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Get
         *
         * <code>
         * <zdoc:get name="string" />
         * </code>
         *
         * @param string name="string"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "get":
            $errorMessage .= ztagParamCheck($arrParam, "name");
            if (isset($_SESSION[$strName])) {
                $arrayTag[$tagId][ztagValue] = $_SESSION["tag_{$strName}"];
            }
            break;
            /*+
             * Unset a session
             *
             * <code>
             * <zsession:unset name="getFiltro" />
             * </code>
             *
             * @param string name="getFiltro"
             */
        /*+
         * Unset a session
         *
         * <code>
         * <zsession:unset name="getFiltro" />
         * </code>
         *
         * @param string name="getFiltro"
         */
        case "unset":
            /*+
             * Reset a session
             *
             * <code>
             * <zsession:reset name="getFiltro" />
             * </code>
             *
             * @param string name="getFiltro"
             */
        /*+
         * Reset a session
         *
         * <code>
         * <zsession:reset name="getFiltro" />
         * </code>
         *
         * @param string name="getFiltro"
         */
        case "reset":
            $errorMessage = ztagParamCheck($arrParam, "name");
            if (isset($_SESSION[$strName])) {
                unset($_SESSION[$strName]);
            }
            break;
            /*+
             * Show
             *
             * <code>
             * <zdoc:show name="string" />
             * </code>
             *
             * @param string name="string"
             *
             * @author Ruben Zevallos Jr. <*****@*****.**>
             */
        /*+
         * Show
         *
         * <code>
         * <zdoc:show name="string" />
         * </code>
         *
         * @param string name="string"
         *
         * @author Ruben Zevallos Jr. <*****@*****.**>
         */
        case "show":
            $errorMessage .= ztagParamCheck($arrParam, "name");
            if (isset($_SESSION[$strName])) {
                $arrayTag[$tagId][ztagResult] = $_SESSION["tag_{$strName}"];
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#20
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zmemcached_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zmemcached_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $strUse = $arrParam["use"];
    $strValue = $arrParam["value"];
    $strKey = $arrParam["key"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * <zmemcached:foreach use="getAll" value="value">
         *   <zhtml:b value="$key" />: <zvar:show use="$value" /><br />
         * </zmemcached:foreach>
         *
         * <zmemcached:foreach use="getAll" key="key" value="value">
         *   <zhtml:b value="$key" />: <zvar:show use="$value" /><br />
         * </zmemcached:foreach>
         *
         * Iterate over arrays executing it's content many time as it's content.
         *
         * use="getAll" Variable array
         * key="key" Variable where the array Key with saved
         * value="value" Variable where the array Value with saved
         *
         */
        case "foreach":
            $errorMessage .= ztagParamCheck($arrParam, "use,value");
            if ($arrayTagId["\$" . $strUse][ztagIdType] != idTypeFVar) {
                $errorMessage .= "<br />The handle \"{$strUse}\" is not a var one!";
            }
            $strArray = $arrayTagId["\$" . $strUse][ztagIdValue];
            $arrayTag[$tagId][ztagResult] = $strValue;
            if (strlen($strValue) && !strlen($strKey)) {
                foreach ($strArray as $value) {
                    $arrayTagId["\$" . $strValue][ztagIdValue] = $value;
                    $arrayTagId["\$" . $strValue][ztagIdType] = idTypeFVar;
                    $arrayTag[$tagId][ztagResult] .= ztagRun($strContent, 0, $arrayTagId);
                }
            } else {
                foreach ($strArray as $key => $value) {
                    $arrayTagId["\$" . $strKey][ztagIdValue] = $key;
                    $arrayTagId["\$" . $strKey][ztagIdType] = idTypeFVar;
                    $arrayTagId["\$" . $strValue][ztagIdValue] = $value;
                    $arrayTagId["\$" . $strValue][ztagIdType] = idTypeFVar;
                    $arrayTag[$tagId][ztagResult] .= ztagRun($strContent, 0, $arrayTagId);
                }
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    /*
      debugError("tagFunction=$tagFunction"
    ."<br />tagId=$tagId"
    ."<br />strId=$strId"
    ."<br />strUse=$strUse"
    ."<br />strValue=$strValue"
    ."<br />arrayTagId[$strId][ztagIdValue]=".$arrayTagId[$strId][ztagIdValue]
    ."<br />arrayTagId[$strUse][ztagIdValue]=".$arrayTagId[$strUse][ztagIdValue]
    ."<br />arrayTag[$tagId][ztagResult]=".$arrayTag[$tagId][ztagResult]);
    */
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#21
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zmemcached_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zmemcached_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $strHost = $arrParam["host"];
    $strPort = $arrParam["port"];
    $strUse = $arrParam["use"];
    $strVar = $arrParam["var"];
    $strKey = $arrParam["key"];
    $strCompress = $arrParam["compress"];
    $strExpire = $arrParam["expire"];
    $strTimeout = $arrParam["timeout"];
    $strValue = $arrParam["value"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Open memcached server connection
         *
         * <code>
         * <zmemcached:open id="memCached" host="localhost" port="11211" timeout="1" />
         * </code>
         *
         * @param string id="menCached" Id of an open connection
         * @param string host="localhost" Point to the host where memcached is listening for connections
         * @param int port="11211" Point to the port where memcached is listening for connections
         * @param int timeout="1" Value in seconds which will be used for connecting to the daemon
         */
        case "open":
            $errorMessage .= ztagParamCheck($arrParam, "id,host,port");
            if (extension_loaded('memcache')) {
                $mcObject = new Memcache();
                if (strlen($strTimeout)) {
                    $mcObject->connect($strHost, $strPort, $strTimeout);
                } else {
                    $mcObject->connect($strHost, $strPort);
                }
                if ($mcObject) {
                    $mcHandle[memcachedHandleHost] = $strHost;
                    $mcHandle[memcachedHandlePort] = $strPort;
                    $mcHandle[memcachedHandleTimeout] = $strTimeout;
                    $mcHandle[memcachedHandleId] = $mcObject;
                    $mcHandle[memcachedHandleState] = dbHandleStateOpen;
                    $arrayTagId[$strId][ztagIdHandle] = $mcHandle;
                    $arrayTagId[$strId][ztagIdType] = idTypeMemCached;
                    $arrayTagId[$strId][ztagIdState] = idStateOpened;
                } else {
                    $errorMessage .= "<br />Could not connect to memcached server {$strHost}:{$strPort}!";
                }
            } else {
                $errorMessage .= "<br />The MemCache extension is not loaded!";
            }
            break;
            /*+
             * Close memcached server connection
             *
             * <code>
             * <zmemcached:close use="memCached" />
             * </code>
             *
             * @param string use="memCached" Id of a open connection
             */
        /*+
         * Close memcached server connection
         *
         * <code>
         * <zmemcached:close use="memCached" />
         * </code>
         *
         * @param string use="memCached" Id of a open connection
         */
        case "close":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeMemCached) {
                $mcHandle = $arrayTagId[$strUse][ztagIdHandle];
                $mcObject = $mcHandle[memcachedHandleId];
                $strHost = $mcHandle[memcachedHandleHost];
                $strPort = $mcHandle[memcachedHandlePort];
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $mcObject = $mcHandle[memcachedHandleId];
                    $mcObject->close();
                    $mcHandle[memcachedHandleId] = $mcObject;
                    $arrayTagId[$strUse][ztagIdHandle] = $mcHandle;
                    $arrayTagId[$strUse][ztagIdState] = idStateClosed;
                } else {
                    $errorMessage .= "<br />The id {$strId} of host {$strHost}:{$strPort} is not open!";
                }
            } else {
                $errorMessage .= "<br />The id {$strId} no not refer to a Memcached handler!";
            }
            break;
            /*+
             * Add a memcached server to connection pool
             *
             * <code>
             * <zmemcached:addserver use="memCached"host="localhost" port="11211" timeout="1" persistent="true|false|0|1" weight="10" retryinterval="10" status="true|false|0|1" />
             * </code>
             *
             * @param string id="menCached" Id of an open connection
             * @param string host="localhost" Point to the host where memcached is listening for connections
             * @param int port="11211" Point to the port where memcached is listening for connections
             * @param int timeout="1" Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow.
             * @param boolean persistent="true|false|0|1" Controls the use of a persistent connection. Default to TRUE.
             * @param int weight="10" Number of buckets to create for this server which in turn control its probability of it being selected. The probability is relative to the total weight of all servers.
             * @param int retryinterval="10" Controls how often a failed server will be retried, the default value is 15 seconds. Setting this parameter to -1 disables automatic retry.
             * @param boolean status="true|false|0|1" Controls if the server should be flagged as online.
             */
        /*+
         * Add a memcached server to connection pool
         *
         * <code>
         * <zmemcached:addserver use="memCached"host="localhost" port="11211" timeout="1" persistent="true|false|0|1" weight="10" retryinterval="10" status="true|false|0|1" />
         * </code>
         *
         * @param string id="menCached" Id of an open connection
         * @param string host="localhost" Point to the host where memcached is listening for connections
         * @param int port="11211" Point to the port where memcached is listening for connections
         * @param int timeout="1" Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow.
         * @param boolean persistent="true|false|0|1" Controls the use of a persistent connection. Default to TRUE.
         * @param int weight="10" Number of buckets to create for this server which in turn control its probability of it being selected. The probability is relative to the total weight of all servers.
         * @param int retryinterval="10" Controls how often a failed server will be retried, the default value is 15 seconds. Setting this parameter to -1 disables automatic retry.
         * @param boolean status="true|false|0|1" Controls if the server should be flagged as online.
         */
        case "addserver":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeMemCached) {
                $mcHandle = $arrayTagId[$strUse][ztagIdHandle];
                $mcObject = $mcHandle[memcachedHandleId];
                $strHost = $mcHandle[memcachedHandleHost];
                $strPort = $mcHandle[memcachedHandlePort];
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $mcObject = $mcHandle[memcachedHandleId];
                    $mcObject->addserver($strHost, $strPort);
                    $mcHandle[memcachedHandleId] = $mcObject;
                    $arrayTagId[$strUse][ztagIdHandle] = $mcHandle;
                } else {
                    $errorMessage .= "<br />The id {$strId} of host {$strHost}:{$strPort} is not open!";
                }
            } else {
                $errorMessage .= "<br />The id {$strId} no not refer to a Memcached handler!";
            }
            break;
            /*+
             * Get Server status
             *
             * <code>
             * <zmemcached:getserverstatus use="memCached" host="localhost" port="11211" var="memcachedStatus" />
             * </code>
             *
             * @param string host="localhost" Point to the host where memcached is listening for connections
             * @param int port="11211" Point to the port where memcached is listening for connections
             */
        /*+
         * Get Server status
         *
         * <code>
         * <zmemcached:getserverstatus use="memCached" host="localhost" port="11211" var="memcachedStatus" />
         * </code>
         *
         * @param string host="localhost" Point to the host where memcached is listening for connections
         * @param int port="11211" Point to the port where memcached is listening for connections
         */
        case "getserverstatus":
            $errorMessage .= ztagParamCheck($arrParam, "use,host,port,var");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeMemCached) {
                $mcHandle = $arrayTagId[$strUse][ztagIdHandle];
                $mcObject = $mcHandle[memcachedHandleId];
                $strHost = $mcHandle[memcachedHandleHost];
                $strPort = $mcHandle[memcachedHandlePort];
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $statusValue = $mcObject->getServerStatus($strHost, $strPort);
                    if ($statusValue) {
                        $arrayTagId["\$" . $strVar][ztagIdValue] = $statusValue;
                        $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
                    }
                } else {
                    $errorMessage .= "<br />The id {$strId} of host {$strHost}:{$strPort} is not open!";
                }
            } else {
                $errorMessage .= "<br />The id {$strId} no not refer to a Memcached handler!";
            }
            break;
            /*+
             * Get Server version
             *
             * <code>
             * <zmemcached:getversion use="memCached" var="versionVar" />
             * </code>
             *
             * @param string use="memCached" Id of an open connection
             * @param string var="versionVar" Variable where data will be set
             */
        /*+
         * Get Server version
         *
         * <code>
         * <zmemcached:getversion use="memCached" var="versionVar" />
         * </code>
         *
         * @param string use="memCached" Id of an open connection
         * @param string var="versionVar" Variable where data will be set
         */
        case "getversion":
            $errorMessage .= ztagParamCheck($arrParam, "use,var");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeMemCached) {
                $mcHandle = $arrayTagId[$strUse][ztagIdHandle];
                $mcObject = $mcHandle[memcachedHandleId];
                $strHost = $mcHandle[memcachedHandleHost];
                $strPort = $mcHandle[memcachedHandlePort];
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $mcObject = $mcHandle[memcachedHandleId];
                    $versionValue = $mcObject->getVersion();
                    if ($versionValue) {
                        $arrayTagId["\$" . $strVar][ztagIdValue] = $versionValue;
                        $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
                    } else {
                        $errorMessage .= "<br />I cannot get the server version from Id {$strId} of host {$strHost}:{$strPort}!";
                    }
                } else {
                    $errorMessage .= "<br />The id {$strId} of host {$strHost}:{$strPort} is not open!";
                }
            } else {
                $errorMessage .= "<br />The id {$strId} no not refer to a Memcached handler!";
            }
            break;
            /*+
             * Close memcached server connection
             *
             * Stats array
             * pid - Process id of this server process
             * uptime - Number of seconds this server has been running
             * time - Current UNIX time according to the server
             * version - Version string of this server
             * rusage_user - Accumulated user time for this process
             * rusage_system - Accumulated system time for this process
             * curr_items - Current number of items stored by the server
             * total_items - Total number of items stored by this server ever since it started
             * bytes - Current number of bytes used by this server to store items
             * curr_connections - Number of open connections
             * total_connections - Total number of connections opened since the server started running
             * connection_structures - Number of connection structures allocated by the server
             * cmd_get - Cumulative number of retrieval requests
             * cmd_set - Cumulative number of storage requests
             * get_hits - Number of keys that have been requested and found present
             * get_misses - Number of items that have been requested and not found
             * bytes_read - Total number of bytes read by this server from network
             * bytes_written - Total number of bytes sent by this server to network
             * limit_maxbytes - Number of bytes this server is allowed to use for storage.
             *
             * <code>
             * <zmemcached:getstats use="memCached" var="statsVar" type="reset" slabid="" limit="" />
             * </code>
             *
             * @param string use="memCached" Id of an open connection
             * @param string type="reset" The type of statistics to fetch. Valid values are {reset, malloc, maps, cachedump, slabs, items, sizes}
             * @param string slabid="" Used in conjunction with type set to cachedump to identify the slab to dump from
             * @param int limit="" Used in conjunction with type set to cachedump to limit the number of entries to dump.
             */
        /*+
         * Close memcached server connection
         *
         * Stats array
         * pid - Process id of this server process
         * uptime - Number of seconds this server has been running
         * time - Current UNIX time according to the server
         * version - Version string of this server
         * rusage_user - Accumulated user time for this process
         * rusage_system - Accumulated system time for this process
         * curr_items - Current number of items stored by the server
         * total_items - Total number of items stored by this server ever since it started
         * bytes - Current number of bytes used by this server to store items
         * curr_connections - Number of open connections
         * total_connections - Total number of connections opened since the server started running
         * connection_structures - Number of connection structures allocated by the server
         * cmd_get - Cumulative number of retrieval requests
         * cmd_set - Cumulative number of storage requests
         * get_hits - Number of keys that have been requested and found present
         * get_misses - Number of items that have been requested and not found
         * bytes_read - Total number of bytes read by this server from network
         * bytes_written - Total number of bytes sent by this server to network
         * limit_maxbytes - Number of bytes this server is allowed to use for storage.
         *
         * <code>
         * <zmemcached:getstats use="memCached" var="statsVar" type="reset" slabid="" limit="" />
         * </code>
         *
         * @param string use="memCached" Id of an open connection
         * @param string type="reset" The type of statistics to fetch. Valid values are {reset, malloc, maps, cachedump, slabs, items, sizes}
         * @param string slabid="" Used in conjunction with type set to cachedump to identify the slab to dump from
         * @param int limit="" Used in conjunction with type set to cachedump to limit the number of entries to dump.
         */
        case "getstats":
            $strType = $arrParam["type"];
            $strSlabId = $arrParam["slabid"];
            $strLimit = $arrParam["limit"];
            $errorMessage .= ztagParamCheck($arrParam, "use,var");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeMemCached) {
                $mcHandle = $arrayTagId[$strUse][ztagIdHandle];
                $mcObject = $mcHandle[memcachedHandleId];
                $strHost = $mcHandle[memcachedHandleHost];
                $strPort = $mcHandle[memcachedHandlePort];
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    $mcObject = $mcHandle[memcachedHandleId];
                    if (strlen($strType) && !strlen($strSlabId)) {
                        $statsValue = $mcObject->getStats($strType);
                    } elseif (strlen($strType) && strlen($strSlabId) && !strlen($strLimit)) {
                        $statsValue = $mcObject->getStats($strType, $strSlabId);
                    } elseif (strlen($strType) && strlen($strSlabId) && strlen($strLimit)) {
                        $statsValue = $mcObject->getStats($strType, $strSlabId, $strLimit);
                    } else {
                        $statsValue = $mcObject->getStats();
                    }
                    if ($statsValue) {
                        $arrayTagId["\$" . $strVar][ztagIdValue] = $statsValue;
                        $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
                    } else {
                        $errorMessage .= "<br />I cannot get stats from Id {$strId} of host {$strHost}:{$strPort}!";
                    }
                } else {
                    $errorMessage .= "<br />The id {$strId} of host {$strHost}:{$strPort} is not open!";
                }
            } else {
                $errorMessage .= "<br />The id {$strId} no not refer to a Memcached handler!";
            }
            break;
            /*+
             * Get Server extended status
             *
             * <code>
             * <zmemcached:getextendedstats host="localhost" port="11211" var="memcachedStatus" />
             * </code>
             *
             * @param string host="localhost" Point to the host where memcached is listening for connections
             * @param int port="11211" Point to the port where memcached is listening for connections
             * @param string var="memcachedStatus"
             */
        /*+
         * Get Server extended status
         *
         * <code>
         * <zmemcached:getextendedstats host="localhost" port="11211" var="memcachedStatus" />
         * </code>
         *
         * @param string host="localhost" Point to the host where memcached is listening for connections
         * @param int port="11211" Point to the port where memcached is listening for connections
         * @param string var="memcachedStatus"
         */
        case "getextendedstats":
            $memcache_obj->getExtendedStats();
            /*
             pid: Process id of this server process
             uptime: Number of seconds this server has been running
             time: Current UNIX time according to the server
             version: Version string of this server
             rusage_user: Accumulated user time for this process
             rusage_system: Accumulated system time for this process
             curr_items: Current number of items stored by the server
             total_items: Total number of items stored by this server ever since it started
             bytes: Current number of bytes used by this server to store items
             curr_connections: Number of open connections
             total_connections: Total number of connections opened since the server started running
             connection_structures: Number of connection structures allocated by the server
             cmd_get: Cumulative number of retrieval requests
             cmd_set: Cumulative number of storage requests
             get_hits: Number of keys that have been requested and found present
             get_misses: Number of items that have been requested and not found
             bytes_read: Total number of bytes read by this server from network
             bytes_written: Total number of bytes sent by this server to network
             limit_maxbytes: Number of bytes this server is allowed to use for storage.
            */
            break;
            /*+
             * Return a hash of your key
             *
             * <code>
             * <zmemcached:key key="My key value" var="versionVar" type="md5|base64" />
             * </code>
             *
             * @param string key="My key value"
             * @param string var="versionVar" Variable where data will be set
             * @param string type="md5|base64" Type of your key
             */
        /*+
         * Return a hash of your key
         *
         * <code>
         * <zmemcached:key key="My key value" var="versionVar" type="md5|base64" />
         * </code>
         *
         * @param string key="My key value"
         * @param string var="versionVar" Variable where data will be set
         * @param string type="md5|base64" Type of your key
         */
        case "key":
            $strType = $arrParam["type"];
            $errorMessage .= ztagParamCheck($arrParam, "key,var");
            switch ($strType) {
                case "md5":
                    $keyValue = md5($strKey);
                    break;
                default:
                    $keyValue = base64_encode($strKey);
            }
            $arrayTagId["\$" . $strVar][ztagIdValue] = $keyValue;
            $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
            break;
            /*+
             * Store data at the server
             *
             * <code>
             * <zmemcached:set use="memCached" key="unique Id for this" value="statsVar" compress="1" expire="0" />
             *
             * <zmemcached:set use="memCached" key="" compress="" expire="">
             *   Value to be Cached
             * </zmemcached:set>
             * </code>
             *
             * @param string use="memCached" Id of an open connection
             * @param string key="unique Id for this" The key that will be associated with the item.
             * @param string value="$valueVar" The variable to store. Strings and integers are stored as is, other types are stored serialized.
             * @param string compress="true|false|1|0" Use MEMCACHE_COMPRESSED to store the item compressed (uses zlib).
             * @param int expire="0" Expiration time of the item. If it's equal to zero, the item will never expire.
             */
        /*+
         * Store data at the server
         *
         * <code>
         * <zmemcached:set use="memCached" key="unique Id for this" value="statsVar" compress="1" expire="0" />
         *
         * <zmemcached:set use="memCached" key="" compress="" expire="">
         *   Value to be Cached
         * </zmemcached:set>
         * </code>
         *
         * @param string use="memCached" Id of an open connection
         * @param string key="unique Id for this" The key that will be associated with the item.
         * @param string value="$valueVar" The variable to store. Strings and integers are stored as is, other types are stored serialized.
         * @param string compress="true|false|1|0" Use MEMCACHE_COMPRESSED to store the item compressed (uses zlib).
         * @param int expire="0" Expiration time of the item. If it's equal to zero, the item will never expire.
         */
        case "set":
            if (strlen($strContent)) {
                $strValue = $strContent;
                $arrParam["value"] = $strValue;
            }
            $errorMessage .= ztagParamCheck($arrParam, "use,key,value");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeMemCached) {
                $mcHandle = $arrayTagId[$strUse][ztagIdHandle];
                $mcObject = $mcHandle[memcachedHandleId];
                $strHost = $mcHandle[memcachedHandleHost];
                $strPort = $mcHandle[memcachedHandlePort];
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    // $resultset = serialize($resultset);
                    if (strlen($strKey) && strlen($strValue) && !strlen($strCompress)) {
                        $setValue = $mcObject->set($strKey, $strValue);
                    } elseif (strlen($strKey) && strlen($strValue) && strlen($strCompress) && !strlen($strExpire)) {
                        if ($strCompress === "true" || $strCompress === 1) {
                            $strCompress = MEMCACHE_COMPRESSED;
                        }
                        $setValue = $mcObject->set($strKey, $strValue, $strCompress);
                    } elseif (strlen($strKey) && strlen($strValue) && strlen($strCompress) && strlen($strExpire)) {
                        $setValue = $mcObject->set($strKey, $strValue, $strCompress, $strExpire);
                    }
                    if (!$setValue) {
                        $errorMessage .= "<br />I cannot set data lenght (" . strlen($strValue) . ") with Key \"{$strKey}\" from to {$strHost}:{$strPort}!";
                    }
                } else {
                    $errorMessage .= "<br />The id {$strUse} of host {$strHost}:{$strPort} is not open!";
                }
            } else {
                $errorMessage .= "<br />The id {$strUse} no not refer to a Memcached handler!";
            }
            break;
            /*+
             * Retrieve item from the server
             *
             * <code>
             * <zmemcached:get use="memCached" key="unique Id for this" var="getVar" flags="" />
             *
             * <zmemcached:get use="memCached" var="getVar" flags="">
             *  keys{"Key one"
             *  , "Key two"
             *  , 'Another key'
             *  , 99}
             * </zmemcached:get>
             * </code>
             *
             * @param string use="memCached" Id of an open connection
             * @param string key="unique Id for this" The key that will be associated with the item.
             * @param string var="$getVar" Variable where the data will be return
             * @param string flags="" Where the flag values that was written at Set
             */
        /*+
         * Retrieve item from the server
         *
         * <code>
         * <zmemcached:get use="memCached" key="unique Id for this" var="getVar" flags="" />
         *
         * <zmemcached:get use="memCached" var="getVar" flags="">
         *  keys{"Key one"
         *  , "Key two"
         *  , 'Another key'
         *  , 99}
         * </zmemcached:get>
         * </code>
         *
         * @param string use="memCached" Id of an open connection
         * @param string key="unique Id for this" The key that will be associated with the item.
         * @param string var="$getVar" Variable where the data will be return
         * @param string flags="" Where the flag values that was written at Set
         */
        case "get":
            if (strlen($strContent)) {
                $strKey = $strContent;
            }
            if (strlen($strKey)) {
                $strKey = ztagVars($strKey, $arrayTagId);
            }
            $arrParam["key"] = $strKey;
            $errorMessage .= ztagParamCheck($arrParam, "use,key,var");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeMemCached) {
                $mcHandle = $arrayTagId[$strUse][ztagIdHandle];
                $mcObject = $mcHandle[memcachedHandleId];
                $strHost = $mcHandle[memcachedHandleHost];
                $strPort = $mcHandle[memcachedHandlePort];
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    if (strlen($strKey) && !strlen($strFlag)) {
                        $getValue = $mcObject->get($strKey);
                    } elseif (strlen($strKey) && strlen($strFlag)) {
                        $getValue = $mcObject->get($strKey, $strFlag);
                    }
                    if (strlen($strVar) && strlen($getValue)) {
                        $arrayTagId["\$" . $strVar][ztagIdValue] = $getValue;
                        $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
                    } else {
                        $arrayTagId["\$" . $strVar] = array();
                    }
                } else {
                    $errorMessage .= "<br />The id {$strUse} of host {$strHost}:{$strPort} is not open!";
                }
            } else {
                $errorMessage .= "<br />The id {$strUse} no not refer to a Memcached handler!";
            }
            break;
            /*+
             * Retrieve item from the server
             *
             * <code>
             * <zmemcached:add use="memCached" key="unique Id for this" var="getVar" flags="" />
             * </code>
             *
             * @param string use="memCached" Id of an open connection
             * @param string key="unique Id for this" The key that will be associated with the item.
             * @param string var="$getVar" Variable where the data will be return
             * @param string flags="" Where the flag values that was written at Set
             */
        /*+
         * Retrieve item from the server
         *
         * <code>
         * <zmemcached:add use="memCached" key="unique Id for this" var="getVar" flags="" />
         * </code>
         *
         * @param string use="memCached" Id of an open connection
         * @param string key="unique Id for this" The key that will be associated with the item.
         * @param string var="$getVar" Variable where the data will be return
         * @param string flags="" Where the flag values that was written at Set
         */
        case "add":
            if (strlen($strContent)) {
                $strValue = $strContent;
            }
            if (strlen($strValue)) {
                $strValue = ztagVars($strValue, $arrayTagId);
            }
            $arrParam["value"] = $strValue;
            $errorMessage .= ztagParamCheck($arrParam, "use,key,value");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeMemCached) {
                $mcHandle = $arrayTagId[$strUse][ztagIdHandle];
                $mcObject = $mcHandle[memcachedHandleId];
                $strHost = $mcHandle[memcachedHandleHost];
                $strPort = $mcHandle[memcachedHandlePort];
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    // $resultset = serialize($resultset);
                    if (strlen($strKey) && strlen($strValue) && !strlen($strFlag)) {
                        $addValue = $mcObject->add($strKey, $strValue);
                    } elseif (strlen($strKey) && strlen($strValue) && strlen($strFlag) && !strlen($strExpire)) {
                        if ($strFlag === "true" || $strFlag === 1) {
                            $strFlag = MEMCACHE_COMPRESSED;
                        }
                        $addValue = $mcObject->add($strKey, $strValue, $strFlag);
                    } elseif (strlen($strKey) && strlen($strValue) && strlen($strFlag) && strlen($strExpire)) {
                        $addValue = $mcObject->add($strKey, $strValue, $strFlag, $strExpire);
                    }
                    if (!$addValue) {
                        $errorMessage .= "<br />I cannot add data to Id {$strId} of host {$strHost}:{$strPort}!";
                    }
                } else {
                    $errorMessage .= "<br />The id {$strId} of host {$strHost}:{$strPort} is not open!";
                }
            } else {
                $errorMessage .= "<br />The id {$strId} no not refer to a Memcached handler!";
            }
            break;
            /*+
             * Replace value of the existing item
             *
             * <code>
             * <zmemcached:replace use="memCached" key="unique Id for this" value="statsVar" compress="1" expire="0" />
             *
             * <zmemcached:replace use="memCached" key="" compress="1" expire="">
             *   Value to be replaced
             * </zmemcached:replace>
             * </code>
             *
             * @param string use="memCached" Id of an open connection
             * @param string key="unique Id for this" The key that will be associated with the item.
             * @param string value="$valueVar" The variable to store. Strings and integers are stored as is, other types are stored serialized.
             * @param string compress="true|false|1|0" Use MEMCACHE_COMPRESSED to store the item compressed (uses zlib).
             * @param int expire="0" Expiration time of the item. If it's equal to zero, the item will never expire.
             */
        /*+
         * Replace value of the existing item
         *
         * <code>
         * <zmemcached:replace use="memCached" key="unique Id for this" value="statsVar" compress="1" expire="0" />
         *
         * <zmemcached:replace use="memCached" key="" compress="1" expire="">
         *   Value to be replaced
         * </zmemcached:replace>
         * </code>
         *
         * @param string use="memCached" Id of an open connection
         * @param string key="unique Id for this" The key that will be associated with the item.
         * @param string value="$valueVar" The variable to store. Strings and integers are stored as is, other types are stored serialized.
         * @param string compress="true|false|1|0" Use MEMCACHE_COMPRESSED to store the item compressed (uses zlib).
         * @param int expire="0" Expiration time of the item. If it's equal to zero, the item will never expire.
         */
        case "replace":
            if (strlen($strContent)) {
                $strValue = $strContent;
            }
            if (strlen($strValue)) {
                $strValue = ztagVars($strValue, $arrayTagId);
            }
            $arrParam["value"] = $strValue;
            $errorMessage .= ztagParamCheck($arrParam, "use,key,value");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeMemCached) {
                $mcHandle = $arrayTagId[$strUse][ztagIdHandle];
                $mcObject = $mcHandle[memcachedHandleId];
                $strHost = $mcHandle[memcachedHandleHost];
                $strPort = $mcHandle[memcachedHandlePort];
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    // $resultset = serialize($resultset);
                    if (strlen($strKey) && strlen($strValue) && !strlen($strFlag)) {
                        $setValue = $mcObject->replace($strKey, $strValue);
                    } elseif (strlen($strKey) && strlen($strValue) && strlen($strFlag) && !strlen($strExpire)) {
                        if ($strFlag === "true" || $strFlag === 1) {
                            $strFlag = MEMCACHE_COMPRESSED;
                        }
                        $setValue = $mcObject->replace($strKey, $strValue, $strFlag);
                    } elseif (strlen($strKey) && strlen($strValue) && strlen($strFlag) && strlen($strExpire)) {
                        $setValue = $mcObject->replace($strKey, $strValue, $strFlag, $strExpire);
                    }
                    if (!$setValue) {
                        $errorMessage .= "<br />I cannot replace data to Id {$strId} of host {$strHost}:{$strPort}!";
                    }
                } else {
                    $errorMessage .= "<br />The id {$strId} of host {$strHost}:{$strPort} is not open!";
                }
            } else {
                $errorMessage .= "<br />The id {$strId} no not refer to a Memcached handler!";
            }
            break;
            /*+
             * Delete item from the server
             *
             * <code>
             * <zmemcached:delete use="memCached" key="unique Id for this" timeout="10" />
             * </code>
             *
             * @param string use="memCached" Id of an open connection
             * @param int timeout="0" Execution time of the item. If it's equal to zero, the item will be deleted right away whereas if you set it to 30, the item will be deleted in 30 seconds.
             */
        /*+
         * Delete item from the server
         *
         * <code>
         * <zmemcached:delete use="memCached" key="unique Id for this" timeout="10" />
         * </code>
         *
         * @param string use="memCached" Id of an open connection
         * @param int timeout="0" Execution time of the item. If it's equal to zero, the item will be deleted right away whereas if you set it to 30, the item will be deleted in 30 seconds.
         */
        case "delete":
            $errorMessage .= ztagParamCheck($arrParam, "use,key");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeMemCached) {
                $mcHandle = $arrayTagId[$strUse][ztagIdHandle];
                $mcObject = $mcHandle[memcachedHandleId];
                $strHost = $mcHandle[memcachedHandleHost];
                $strPort = $mcHandle[memcachedHandlePort];
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    // $resultset = serialize($resultset);
                    if (strlen($strKey) && !strlen($strTimeout)) {
                        $setValue = $mcObject->delete($strKey);
                    } elseif (strlen($strKey) && strlen($strTimeout)) {
                        $setValue = $mcObject->delete($strKey, $strTimeout);
                    }
                    if (!$setValue) {
                        $errorMessage .= "<br />I cannot delete data to Id {$strId} of host {$strHost}:{$strPort}!";
                    }
                } else {
                    $errorMessage .= "<br />The id {$strId} of host {$strHost}:{$strPort} is not open!";
                }
            } else {
                $errorMessage .= "<br />The id {$strId} no not refer to a Memcached handler!";
            }
            break;
            /*+
             * Increment item's value
             *
             * <code>
             * <zmemcached:increment use="memCached" key="unique Id for this" value="1" />
             * </code>
             *
             * @param string use="memCached" Id of an open connection
             * @param int value="1" Value to be incremented
             */
        /*+
         * Increment item's value
         *
         * <code>
         * <zmemcached:increment use="memCached" key="unique Id for this" value="1" />
         * </code>
         *
         * @param string use="memCached" Id of an open connection
         * @param int value="1" Value to be incremented
         */
        case "increment":
            $errorMessage .= ztagParamCheck($arrParam, "use,key");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeMemCached) {
                $mcHandle = $arrayTagId[$strUse][ztagIdHandle];
                $mcObject = $mcHandle[memcachedHandleId];
                $strHost = $mcHandle[memcachedHandleHost];
                $strPort = $mcHandle[memcachedHandlePort];
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    if (strlen($strKey) && !strlen($strValue)) {
                        $setValue = $mcObject->increment($strKey);
                    } elseif (strlen($strKey) && strlen($strValue)) {
                        $setValue = $mcObject->increment($strKey, $strValue);
                    }
                    if (!$setValue) {
                        $errorMessage .= "<br />I cannot increment data to Id {$strId} of host {$strHost}:{$strPort}!";
                    }
                } else {
                    $errorMessage .= "<br />The id {$strId} of host {$strHost}:{$strPort} is not open!";
                }
            } else {
                $errorMessage .= "<br />The id {$strId} no not refer to a Memcached handler!";
            }
            break;
            /*+
             * Decrement item's value
             *
             * <code>
             * <zmemcached:decrement use="memCached" key="unique Id for this" value="1" />
             * </code>
             *
             * @param string use="memCached" Id of an open connection
             * @param int value="1" Value to be incremented
             */
        /*+
         * Decrement item's value
         *
         * <code>
         * <zmemcached:decrement use="memCached" key="unique Id for this" value="1" />
         * </code>
         *
         * @param string use="memCached" Id of an open connection
         * @param int value="1" Value to be incremented
         */
        case "decrement":
            $errorMessage .= ztagParamCheck($arrParam, "use,key");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeMemCached) {
                $mcHandle = $arrayTagId[$strUse][ztagIdHandle];
                $mcObject = $mcHandle[memcachedHandleId];
                $strHost = $mcHandle[memcachedHandleHost];
                $strPort = $mcHandle[memcachedHandlePort];
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    if (strlen($strKey) && !strlen($strValue)) {
                        $setValue = $mcObject->decrement($strKey);
                    } elseif (strlen($strKey) && strlen($strValue)) {
                        $setValue = $mcObject->decrement($strKey, $strValue);
                    }
                    if (!$setValue) {
                        $errorMessage .= "<br />I cannot decrement data to Id {$strId} of host {$strHost}:{$strPort}!";
                    }
                } else {
                    $errorMessage .= "<br />The id {$strId} of host {$strHost}:{$strPort} is not open!";
                }
            } else {
                $errorMessage .= "<br />The id {$strId} no not refer to a Memcached handler!";
            }
            break;
            /*+
             * Debug
             *
             * <code>
             * <zmemcached:debug use="memCached" />
             * </code>
             *
             * @param string use="memCached" Id of an open connection
             */
        /*+
         * Debug
         *
         * <code>
         * <zmemcached:debug use="memCached" />
         * </code>
         *
         * @param string use="memCached" Id of an open connection
         */
        case "debug":
            for ($i = 0; $i < count($this->connections); $i++) {
                if ($this->connections[$i]->debug($on_off)) {
                    $result = true;
                }
            }
            break;
            /*+
             * Flush all existing items at the server
             *
             * <code>
             * <zmemcached:flush use="memCached" />
             * </code>
             *
             * @param string use="memCached" Id of an open connection
             */
        /*+
         * Flush all existing items at the server
         *
         * <code>
         * <zmemcached:flush use="memCached" />
         * </code>
         *
         * @param string use="memCached" Id of an open connection
         */
        case "flush":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            if ($arrayTagId[$strUse][ztagIdType] === idTypeMemCached) {
                $mcHandle = $arrayTagId[$strUse][ztagIdHandle];
                $mcObject = $mcHandle[memcachedHandleId];
                $strHost = $mcHandle[memcachedHandleHost];
                $strPort = $mcHandle[memcachedHandlePort];
                if ($arrayTagId[$strUse][ztagIdState] === idStateOpened) {
                    // $resultset = serialize($resultset);
                    $setValue = $mcObject->flush();
                    if (!$setValue) {
                        $errorMessage .= "<br />I cannot flush the Id {$strId} of host {$strHost}:{$strPort}!";
                    }
                } else {
                    $errorMessage .= "<br />The id {$strId} of host {$strHost}:{$strPort} is not open!";
                }
            } else {
                $errorMessage .= "<br />The id {$strId} no not refer to a Memcached handler!";
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}
示例#22
0
/**
 * Main zTag functions selector
 *
 * <code>
 * zctrl_execute($tagId, $tagFunction, $arrayTag, $arrayTagId, $arrayOrder);
 * </code>
 *
 * @param integer $tagId array id of current zTag of $arrayTag array
 * @param string $tagFunction name of zTag function
 * @param array $arrayTag array with all compiled zTags
 * @param array $arrayTagId array with all Ids values
 * @param array $arrayOrder array with zTag executing order
 *
 * @since 1.0
 */
function zctrl_zexecute($tagId, $tagFunction, &$arrayTag, &$arrayTagId, $arrayOrder)
{
    global $ztagExit;
    $arrParam = $arrayTag[$tagId][ztagParam];
    $strId = $arrParam["id"];
    $strUse = $arrParam["use"];
    $strValue = $arrParam["value"];
    $strKey = $arrParam["key"];
    $strTransform = $arrParam["transform"];
    $strMessage = $arrParam["message"];
    if ($arrayTag[$tagId][ztagContentWidth]) {
        $strContent = $arrayTag[$tagId][ztagContent];
    }
    $errorMessage = "";
    switch (strtolower($tagFunction)) {
        /*+
         * Iterate over arrays executing it's content many time as it's content.
         *
         * <code>
         * <zctrl:foreach use="getAll" value="value">
         *   <zhtml:b value="$key" />: <zvar:show use="$value" /><br />
         * </zctrl:foreach>
         *
         * <zctrl:foreach use="getAll" key="key" value="value">
         *   <zhtml:b value="$key" />: <zvar:show use="$value" /><br />
         * </zctrl:foreach>
         * </code>
         *
         * @param string use="getAll" Variable array
         * @param string key="key" Variable where the array Key with saved
         * @param string value="value" Variable where the array Value with saved
         * @param string filename="/Alianca8/File.txt"
         * @param string filetype="txt"
         * @param string show="0"
         */
        case "foreach":
            $strFileName = $arrParam["filename"];
            $strFileType = $arrParam["filetype"];
            $strShow = strtolower($arrParam["show"]);
            $errorMessage .= ztagParamCheck($arrParam, "use,value");
            if ($arrayTagId["\$" . $strUse][ztagIdType] != idTypeFVar) {
                $errorMessage .= "<br />The handle \"{$strUse}\" is not a var one!";
            }
            // $strArray = $arrayTagId["$".$strUse][ztagIdValue];
            preg_match_all('%^(?P<var>\\w+)\\[(?P<index>[^\\]]+)\\]$%', $strUse, $Matches, PREG_OFFSET_CAPTURE);
            if (count($Matches[0][0])) {
                $var = $Matches["var"][0][0];
                $index = $Matches["index"][0][0];
                $strArray = $arrayTagId["\$" . $var][ztagIdValue];
                $strArray = $strArray[$index];
            } else {
                if ($arrayTagId["\$" . $strUse][ztagIdType] != idTypeFVar) {
                    $errorMessage .= "<br />The handle \"{$strUse}\" is not a var one!";
                }
                $strArray = $arrayTagId["\$" . $strUse][ztagIdValue];
            }
            if (is_array($strArray)) {
                if (strlen($strValue) && !strlen($strKey)) {
                    foreach ($strArray as $value) {
                        $arrayTagId["\$" . $strValue][ztagIdValue] = $value;
                        $arrayTagId["\$" . $strValue][ztagIdType] = idTypeFVar;
                        $arrayTag[$tagId][ztagResult] .= ztagRun($strContent, 0, $arrayTagId);
                        if ($ztagExit) {
                            break;
                        }
                    }
                } else {
                    foreach ($strArray as $key => $value) {
                        $arrayTagId["\$" . $strKey][ztagIdValue] = $key;
                        $arrayTagId["\$" . $strKey][ztagIdType] = idTypeFVar;
                        $arrayTagId["\$" . $strValue][ztagIdValue] = $value;
                        $arrayTagId["\$" . $strValue][ztagIdType] = idTypeFVar;
                        $arrayTag[$tagId][ztagResult] .= ztagRun($strContent, 0, $arrayTagId);
                        if ($ztagExit) {
                            break;
                        }
                    }
                }
                if ($strFileName) {
                    $strFileName = str_replace("\\", "/", $strFileName);
                    if (substr($strFileName, 0, 1) === "/") {
                        $strFileName = substr($strFileName, 1);
                    }
                    $strFileName = SiteRootDir . $strFileName;
                    if (!($handleFile = fopen($strFileName, "w"))) {
                        $errorMessage .= "\r\nCannot open file ({$strFileName})";
                    } else {
                        if (fwrite($handleFile, $arrayTag[$tagId][ztagResult]) === FALSE) {
                            $errorMessage .= "\r\nCannot write to file ({$strFileName})";
                        }
                    }
                    fclose($handleFile);
                }
                if ($strShow === "false" || $strShow === "0") {
                    $arrayTag[$tagId][ztagResult] = "";
                }
            }
            break;
            /*+
             * Define a conditional execution of code fragments.
             *
             * <code>
             * <zctrl:if value="$urlAssunto0" operator="e|ne|gt|gte|lt|lte" with="0" var="ifVar" >
             * </zctrl:if>
             *
             * <zctrl:if value="$urlAssunto0" function="empty()|true()|false()|len()">
             * </zctrl:if>
             *
             * <zctrl:if value="$urlAssunto0" transform="substr(1, 3)" operator="=|<>|>|>=|<|=" with="test">
             * </zctrl:if>
             * </code>
             *
             * @param string value="value" Variable or value to be used.
             * @param string operator="e|ne|gt|gte|lt|lte" operator to be used
             * @param string with="0" second part of an boolean expression
             * @param string transform="substr(1, 3)" Tranform the value's content
             * @param string function="empty()|true()|false()|len()" Apply a function to value's content and check if result is true
             * @param string var="ifVar" Variable to save all if result
             * @param string show="1|0|true|false" False to not show the If result content
             */
        /*+
         * Define a conditional execution of code fragments.
         *
         * <code>
         * <zctrl:if value="$urlAssunto0" operator="e|ne|gt|gte|lt|lte" with="0" var="ifVar" >
         * </zctrl:if>
         *
         * <zctrl:if value="$urlAssunto0" function="empty()|true()|false()|len()">
         * </zctrl:if>
         *
         * <zctrl:if value="$urlAssunto0" transform="substr(1, 3)" operator="=|<>|>|>=|<|=" with="test">
         * </zctrl:if>
         * </code>
         *
         * @param string value="value" Variable or value to be used.
         * @param string operator="e|ne|gt|gte|lt|lte" operator to be used
         * @param string with="0" second part of an boolean expression
         * @param string transform="substr(1, 3)" Tranform the value's content
         * @param string function="empty()|true()|false()|len()" Apply a function to value's content and check if result is true
         * @param string var="ifVar" Variable to save all if result
         * @param string show="1|0|true|false" False to not show the If result content
         */
        case "if":
            $strOperator = $arrParam["operator"];
            $strWith = $arrParam["with"];
            $strFunction = $arrParam["function"];
            $strVar = $arrParam["var"];
            $strShow = $arrParam["show"];
            if (strlen($strOperator)) {
                $errorMessage .= ztagParamCheck($arrParam, "value,operator,with");
                if (strlen($strTransform)) {
                    $strValue = ztagTransform($strValue, $strTransform);
                }
                switch (strtolower($strOperator)) {
                    case "e":
                        $strOperator = "==";
                        break;
                    case "ne":
                        $strOperator = "<>";
                        break;
                    case "gt":
                        $strOperator = ">";
                        break;
                    case "gte|lt|lte":
                        $strOperator = ">=";
                        break;
                    case "lt|lte":
                        $strOperator = "<";
                        break;
                    case "lte":
                        $strOperator = "<=";
                        break;
                    default:
                        $errorMessage .= "<br />Operator \"{$strOperator}\" does not exist!";
                }
                $strEVal = "if(\$strValue {$strOperator} \$strWith) {return 1;} else {return 0;}";
                $strValue = eval($strEVal);
            } else {
                if (strlen($strFunction)) {
                    $errorMessage .= ztagParamCheck($arrParam, "value,function");
                    if (strlen($strTransform)) {
                        $strValue = ztagTransform($strValue, $strTransform);
                    }
                    if (strlen($strFunction)) {
                        $strValue = ztagTransform($strValue, $strFunction);
                    }
                } else {
                    $errorMessage .= ztagParamCheck($arrParam, "value,function");
                }
            }
            if ($strValue) {
                $getValue .= ztagRun($strContent, 0, $arrayTagId);
                if (($strShow != "false" || $strShow != "0") && strlen($getValue)) {
                    $arrayTag[$tagId][ztagResult] = $getValue;
                }
                if (strlen($strVar) && strlen($getValue)) {
                    $arrayTagId["\$" . $strVar][ztagIdValue] = $getValue;
                    $arrayTagId["\$" . $strVar][ztagIdLength] = strlen($getValue);
                    $arrayTagId["\$" . $strVar][ztagIdType] = idTypeFVar;
                }
            }
            break;
            /*+
             * Output a message and terminate the current script.
             *
             * <code>
             * <zctrl:die message="The script die here!" />
             *
             * <zctrl:die>
             *   The script die here!
             * </zctrl:die>
             * </code>
             *
             * @param string message="value" Variable or value to be printed
             */
        /*+
         * Output a message and terminate the current script.
         *
         * <code>
         * <zctrl:die message="The script die here!" />
         *
         * <zctrl:die>
         *   The script die here!
         * </zctrl:die>
         * </code>
         *
         * @param string message="value" Variable or value to be printed
         */
        case "die":
            /*+
             * Output a message and terminate the current script.
             *
             * <code>
             * <zctrl:exit message="The script exited here!" />
             *
             * <zctrl:exit>
             *   The script exit here!
             * </zctrl:exit>
             * </code>
             *
             * @param string message="value" Variable or value to be printed
             */
        /*+
         * Output a message and terminate the current script.
         *
         * <code>
         * <zctrl:exit message="The script exited here!" />
         *
         * <zctrl:exit>
         *   The script exit here!
         * </zctrl:exit>
         * </code>
         *
         * @param string message="value" Variable or value to be printed
         */
        case "exit":
            $ztagExit = 1;
            if (strlen($strContent)) {
                $strMessage = ztagVars($strContent, $arrayTagId);
            }
            if (strlen($strMessage)) {
                $arrayTag[$tagId][ztagResult] = $strMessage;
            }
            break;
            /*+
             * Output a string
             *
             * <code>
             * <zctrl:echo message="This an echo message" />
             *
             * <zctrl:echo>
             * This an echo message
             * </zctrl:echo>
             * </code>
             *
             * @param string message="value" Variable or value to be used
             */
        /*+
         * Output a string
         *
         * <code>
         * <zctrl:echo message="This an echo message" />
         *
         * <zctrl:echo>
         * This an echo message
         * </zctrl:echo>
         * </code>
         *
         * @param string message="value" Variable or value to be used
         */
        case "echo":
            /*+
             * Output a string
             *
             * <code>
             * <zctrl:print message="This a print message" />
             *
             * <zctrl:print>
             * This a print message
             * </zctrl:print>
             * </code>
             *
             * @param string message="value" Variable or value to be used
             */
        /*+
         * Output a string
         *
         * <code>
         * <zctrl:print message="This a print message" />
         *
         * <zctrl:print>
         * This a print message
         * </zctrl:print>
         * </code>
         *
         * @param string message="value" Variable or value to be used
         */
        case "print":
            if (strlen($strContent)) {
                $strMessage = ztagVars($strContent, $arrayTagId);
                $arrParam["message"] = $strMessage;
            }
            $errorMessage .= ztagParamCheck($arrParam, "message");
            if (strlen($strTransform) && strlen($strMessage)) {
                $strMessage = ztagTransform($strMessage, $strTransform);
            }
            if (strlen($strMessage)) {
                ztagError($strMessage, $arrayTag, $tagId);
            }
            break;
            /*+
             * Dumps information about a variable
             *
             * <code>
             * <zctrl:dump message="<b>arrayDump</b>=" use="arrayDump" />
             * </code>
             *
             * @param string use="arrayDump" Variable to be dumped
             * @param string message="Message" Message to complement the Dump
             */
        /*+
         * Dumps information about a variable
         *
         * <code>
         * <zctrl:dump message="<b>arrayDump</b>=" use="arrayDump" />
         * </code>
         *
         * @param string use="arrayDump" Variable to be dumped
         * @param string message="Message" Message to complement the Dump
         */
        case "dump":
            $errorMessage .= ztagParamCheck($arrParam, "use");
            // echo "<hr><pre>".print_r($strUse,1)."</pre>";
            // echo "<hr><pre>".print_r($arrayTagId["$".$strUse][ztagIdValue],1)."</pre>";
            ztagError($strMessage . var_dump($arrayTagId["\$" . $strUse][ztagIdValue]), $arrayTag, $tagId);
            break;
            /*+
             * Prints human-readable information about a variable
             *
             * <code>
             * <zctrl:printr message="<b>arrayDump</b>=" use="arrayDump" />
             * </code>
             *
             * @param string use="arrayDump" Variable to be printed
             * @param string message="Message" Message to complement the Dump
             */
        /*+
         * Prints human-readable information about a variable
         *
         * <code>
         * <zctrl:printr message="<b>arrayDump</b>=" use="arrayDump" />
         * </code>
         *
         * @param string use="arrayDump" Variable to be printed
         * @param string message="Message" Message to complement the Dump
         */
        case "printr":
            ztagError(print_r($arrayTagId, 1), $arrayTag, $tagId);
            $errorMessage .= ztagParamCheck($arrParam, "use");
            ztagError($strMessage . print_r($arrayTagId["\$" . $strUse][ztagIdValue], 1), $arrayTag, $tagId);
            break;
            /*+
             * Iterate over arrays executing it's content many time as it's content.
             *
             * <code>
             * <zctrl:while value="$urlAssunto0" operator="e|ne|gt|gte|lt|lte" with="0" var="ifVar" >
             * </zctrl:while>
             *
             * <zctrl:while value="$urlAssunto0" function="empty()|true()|false()|len()">
             * </zctrl:while>
             *
             * <zctrl:while value="$urlAssunto0" transform="substr(1, 3)" operator="=|<>|>|>=|<|=" with="test">
             * </code>
             *
             * @param string use="getAll" Variable array
             * @param string key="key" Variable where the array Key with saved
             * @param string value="value" Variable where the array Value with saved
             */
        /*+
         * Iterate over arrays executing it's content many time as it's content.
         *
         * <code>
         * <zctrl:while value="$urlAssunto0" operator="e|ne|gt|gte|lt|lte" with="0" var="ifVar" >
         * </zctrl:while>
         *
         * <zctrl:while value="$urlAssunto0" function="empty()|true()|false()|len()">
         * </zctrl:while>
         *
         * <zctrl:while value="$urlAssunto0" transform="substr(1, 3)" operator="=|<>|>|>=|<|=" with="test">
         * </code>
         *
         * @param string use="getAll" Variable array
         * @param string key="key" Variable where the array Key with saved
         * @param string value="value" Variable where the array Value with saved
         */
        case "while":
            $errorMessage .= ztagParamCheck($arrParam, "use,value");
            if ($arrayTagId["\$" . $strUse][ztagIdType] != idTypeFVar) {
                $errorMessage .= "<br />The handle \"{$strUse}\" is not a var one!";
            }
            $strArray = $arrayTagId["\$" . $strUse][ztagIdValue];
            if (is_array($strArray)) {
                if (strlen($strValue) && !strlen($strKey)) {
                    foreach ($strArray as $value) {
                        $arrayTagId["\$" . $strValue][ztagIdValue] = $value;
                        $arrayTagId["\$" . $strValue][ztagIdType] = idTypeFVar;
                        $arrayTag[$tagId][ztagResult] .= ztagRun($strContent, 0, $arrayTagId);
                        if ($ztagExit) {
                            break;
                        }
                    }
                } else {
                    foreach ($strArray as $key => $value) {
                        $arrayTagId["\$" . $strKey][ztagIdValue] = $key;
                        $arrayTagId["\$" . $strKey][ztagIdType] = idTypeFVar;
                        $arrayTagId["\$" . $strValue][ztagIdValue] = $value;
                        $arrayTagId["\$" . $strValue][ztagIdType] = idTypeFVar;
                        $arrayTag[$tagId][ztagResult] .= ztagRun($strContent, 0, $arrayTagId);
                        if ($ztagExit) {
                            break;
                        }
                    }
                }
            }
            break;
        default:
            $errorMessage .= "<br />Undefined function \"{$tagFunction}\"";
    }
    ztagError($errorMessage, $arrayTag, $tagId);
}