public static function FindEndBlock($st, $posStart, $tagStartBlock, $tagEndBlock, $tagAltEnd = '', $recursionLevel = 0) { // Recursive. Example for IF blocks: Find {ELSE} ($tagAltEnd = "{ELSE}") or {ENDIF} corresponding to this IF (considering possible subblocks) // ATTENTION: $posStart must be AFTER the start of the current block (after pos of first character of $tagStartBlock opening current block) $recursionLevel++; //if ($recursionOn) OEDynUtils::$cntrFindEndBlock++; if ($recursionLevel > 200) { // too long recursion, error OEDynUtils::OutputStop('Error in Page Dynamic Structure - probably no matching {ENDIF} in format:<br/>' . $st); //echo '<br><br>string:'.substr($st, $posStart).'<br><br>'; } $posEND = strpos($st, $tagEndBlock, $posStart); $posAltEND = !$tagAltEnd ? $posEND : strpos($st, $tagAltEnd, $posStart); if ($posEND === false) { return -1; } // error in format if ($posAltEND === false || $posAltEND > $posEND) { $posAltEND = $posEND; } // endif is found first, means $tagAltEnd is absent until the end of block //echo 'end block:'.substr($st, $posAltEND).'<br/>'; $posSubBlock = strpos($st, $tagStartBlock, $posStart); // find first subblock, if any,.. if ($posSubBlock !== false && $posAltEND < $posSubBlock) { $posSubBlock = false; } // .. only if before end of current block if ($posSubBlock === false) { // no subblocks util end of block return $posAltEND; } else { // subblock found $posEndSub = OEDynUtils::FindEndBlock($st, $posSubBlock + 1, $tagStartBlock, $tagEndBlock, '', $recursionLevel); // find end of subblock (it may contain its own subblocks) if ($posEndSub === false) { return -1; } // error in format $recursionLevel--; return OEDynUtils::FindEndBlock($st, $posEndSub + 1, $tagStartBlock, $tagEndBlock, $tagAltEnd, $recursionLevel); // recursive-continue searching from end of subblock (there may be several subblocks on the same level) } }
protected function _connect($params) { //echo 'Connecting start:';var_dump($this); if (!$this->sqliteOk || !isset($params['dbname'])) { $this->_sqliteerrorexit('SQLite engine not initialized'); return false; } // make sure directory for the database file exists: global $dynManager; $relPath = isset($dynManager->JSData['PageRelPath']) ? $dynManager->JSData['PageRelPath'] : ''; if (!$this->_handleDBFolder($relPath, $params['dbname'])) { return false; } if ($this->sqliteVers >= 3) { if (!defined('SQLITE3_INTEGER')) { // sometimes these constants are not defined define('SQLITE3_INTEGER', 1); define('SQLITE3_FLOAT', 2); define('SQLITE3_TEXT', 3); define('SQLITE3_BLOB', 4); } if (!$this->modePDO) { // direct SQLite try { $this->sqlConn = new SQLite3($relPath . $params['dbname']); } catch (Exception $ex) { $message = 'SQLite database creation error : cannot create database. It may happen if the full path to your project contains accented characters or other non-basic symbols. Please copy your project folder to another place, ex. C:\\OEProjects\\MySite(1), and try again<br/><br/>' . 'SQLite - erreur de creation de base de donnees: impossible de creer la base. Ca peut arriver si le chemin complet vers votre projet contient des caracteres accentes (speciaux) ou d\'autres symboles non-basiques. Veuillez copier le dossier de votre projet a un autre emplacement, par exemple C:\\OEProjects\\MonSite(1), et re-essayez<br/><br/>'; OEDynUtils::OutputStop($message); // stop PHP } $this->typeCorrespondence['s'] = SQLITE3_TEXT; $this->typeCorrespondence['i'] = SQLITE3_INTEGER; $this->typeCorrespondence['d'] = SQLITE3_FLOAT; } else { // PDO mode $this->sqlConn = new PDO('sqlite:' . $relPath . $params['dbname']); $this->sqlConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // check $this->typeCorrespondence['s'] = defined('PDO::PARAM_STR') ? PDO::PARAM_STR : PDO_PARAM_STR; $this->typeCorrespondence['i'] = defined('PDO::PARAM_INT') ? PDO::PARAM_INT : PDO_PARAM_INT; $this->typeCorrespondence['d'] = $this->typeCorrespondence['s']; //echo 'Connecting PDO SQLite:';var_dump($this->sqlConn);echo ' db:'.$relPath.$params['dbname'].'<br>'; } if (!$this->sqlConn) { $this->_sqliteerrorexit('SQLite engine not initialized'); } return !!$this->sqlConn; } else { $this->_sqliteerrorexit('SQLite engine not initialized'); return false; } }
function __OutputStop() { $params = $this->Params; $message = isset($params['ErrorMsg']) ? $this->_GetParamDBValue('ErrorMsg') : "Unknown error in website dynamic functionality"; OEDynUtils::OutputStop($message, !$this->Manager->modeAJAX); // stop PHP }