public function build_http_to_https($html) { $blog_url = home_url(); return Patterns::build_http_to_https($html, $blog_url); }
/** * Checks for noncompiling or dangerous regex * @param array $rewrite rewrite arguments to be evaluated for dangerous or noncompiling regex * @param string $domain the domain argument passed in the rewrite rules * @param string $pattern regex pattern passed in the rewrite rules * @param string $argmatch optional regex arg passed in rewrite rules * @param string $replacement rewrite rule's replacement arg * @param bool $quiet (Default: false) if false turns output buffering off and displays errors, true buffers outputs to keep unit-tests clean * @return bool $skip if true, the regex didn't compile or dangerous regex was found and this rewrite will be skipped, if true the regex was safe */ public static function is_scary_regex($rewrite, $domain, $pattern, $argmatch, $replacement, $quiet = false) { $filterees = array($domain, $pattern, $argmatch); $skip = false; foreach ($filterees as $key) { if (!isset($rewrite[$key])) { continue; } if (!Patterns::check_for_noncompiled_regex_string($rewrite[$key], $quiet)) { $skip = true; } if (!Patterns::reject_dangerous_regex_string($rewrite[$key], $quiet)) { $skip = true; } } if (!Patterns::reject_dangerous_regex_string($rewrite[$replacement], $quiet)) { $skip = true; } return $skip; }
public static function disableOrSpace() { return self::$useOrSpace = false; }
$_POST['sql'] = isset($_POST['sql']) ? trim($_POST['sql']) : ''; if (isset($_POST['db'])) { $obj = new SQL(); $factory = $obj->setDb(SQL::DB_SQLITE)->factory(); if (!$factory) { echo Helper_View::message(Language::get('sql_connect_false'), Helper_View::MESSAGE_ERROR); } else { if (isset($_POST['backup'])) { if (isset($_POST['file']) && $_POST['file']) { echo $factory->backup('', '', '', $_POST['db'], $_POST['charset'], array('tables' => isset($_POST['tables']) ? array_map('rawurldecode', $_POST['tables']) : array(), 'data' => isset($_POST['data']) ? array_map('rawurldecode', $_POST['data']) : array(), 'file' => $_POST['file'])); } else { $tables = $factory->backup('', '', '', $_POST['db'], $_POST['charset'], array()); echo '<div class="input"><form action="change.php?go=sqlite&c=' . Registry::get('rCurrent') . '" method="post"><div>' . Language::get('sql_backup_structure') . '<br/><select name="tables[]" multiple="true" size="5">' . $tables . '</select><br/>' . Language::get('sql_backup_data') . '<br/><select name="data[]" multiple="true" size="5">' . $tables . '</select><br/>' . Language::get('file') . '<br/><input type="text" name="file" value="' . Registry::get('hCurrent') . 'backup_' . htmlspecialchars(Helper_System::basename($_POST['db'])) . '.sql"/><br/><input type="hidden" name="db" value="' . htmlspecialchars($_POST['db']) . '"/><input type="hidden" name="charset" value="' . htmlspecialchars($_POST['charset']) . '"/><input type="submit" name="backup" value="' . Language::get('sql_backup') . '"/></div></form></div>'; } } else { $Patterns = new Patterns(); if (!$_POST['sql']) { $_POST['sql'] = 'SELECT name FROM sqlite_master WHERE type = "table" ORDER BY name'; } echo '<div> ' . $_POST['db'] . '<br/></div>' . $factory->query('', '', '', Gmanager::getInstance()->realpath($_POST['db']), $_POST['charset'], $_POST['sql']) . '<div><form action=""><div><textarea rows="' . (mb_substr_count($_POST['sql'], "\n") + 1) . '" cols="48">' . htmlspecialchars($_POST['sql'], ENT_NOQUOTES) . '</textarea></div></form></div><div class="input"><form action="change.php?go=sqlite&c=' . Registry::get('rCurrent') . '" method="post" id="post"><div>' . Language::get('sql_query') . ' <select id="ptn" onchange="Gmanager.paste(this.value);">' . $Patterns->set(array(Patterns::SQLite))->getOptions() . '</select><br/><textarea class="lines" id="sql" name="sql" rows="6" cols="48"></textarea><br/><input type="hidden" name="db" value="' . htmlspecialchars($_POST['db']) . '"/><input type="hidden" name="charset" value="' . htmlspecialchars($_POST['charset']) . '"/><input type="submit" value="' . Language::get('sql') . '"/> <input type="submit" name="backup" value="' . Language::get('sql_backup') . '"/></div></form></div>'; } } } else { echo '<div class="input"><form action="change.php?go=sqlite&c=' . Registry::get('rCurrent') . '" method="post" id="post"><div>' . Language::get('sql_db') . '<br/><input type="text" name="db" value="' . Registry::get('hCurrent') . '"/><br/>' . Language::get('charset') . '<br/><input type="text" name="charset" value="utf8"/><br/>' . Language::get('sql_query') . '<br/><textarea class="lines" id="sql" name="sql" rows="4" cols="48">' . htmlspecialchars($_POST['sql'], ENT_NOQUOTES) . '</textarea><br/><input type="submit" value="' . Language::get('sql') . '"/></div></form></div>'; } break; case 'sql_tables': echo '<div class="input">» ' . Language::get('select_database') . '<br/><div class="red"><ul><li><a href="change.php?go=sql_tables_mysql&c=' . Registry::get('rCurrent') . '">MySQL</a></li><li><a href="change.php?go=sql_tables_postgresql&c=' . Registry::get('rCurrent') . '">PostgreSQL</a></li><li><a href="change.php?go=sql_tables_sqlite&c=' . Registry::get('rCurrent') . '">SQLite</a></li></ul></div></div>'; break; case 'sql_tables_mysql': if (!(isset($_POST['tables']) && Gmanager::getInstance()->is_file($_POST['tables'])) && !(isset($_FILES['f_tables']) && !$_FILES['f_tables']['error'])) {
private function parseTarget($target) { $tokenList = $this->getTokenList(); $tokenReg = join('|', array_map(function ($token) { return preg_quote($token, '/'); }, array_merge($tokenList, [" "]))); $tokens = preg_split('/(' . $tokenReg . ')/', $target, null, PREG_SPLIT_DELIM_CAPTURE); $tmp = []; if (empty($tokens[0])) { array_shift($tokens); } $last = array_pop($tokens); if (!empty($last)) { array_push($tokens, $last); } $this->setTargetTokens($target, $tokens); foreach ($tokens as $key => $token) { if (in_array($token, $this->getKeywords())) { $tmp[] = $token; } else { if (in_array($token, $tokenList)) { $tmp[] = Patterns::getTokenPattern($token); } else { $pattern = Patterns::match($token); if (!$pattern) { if (isset($tokens[$key + 1])) { $pattern = Patterns::getAntiPattern($tokens[$key + 1]); } else { $pattern = Patterns::getAsteriskPattern(); } } $tmp[] = $pattern; } } } $this->setTargetPatterns($target, $tmp); }