Ejemplo n.º 1
0
<?php

require_once 'inc.config.php';
list($_db) = requireParams('db');
require_once 'inc.database.php';
require_once 'tpl.header.php';
require_once 'tpl.database.php';
$tables = $db->getTables();
?>
<style>
.result-meta {
	background-color: #ddd;
	margin-top: 3px;
	padding: 3px;
}
.result-meta.success {
	color: green;
}
.result-meta.error {
	padding: 8px;
	background-color: red;
	color: #fff;
}
</style>

<fieldset>
	<legend>Tables</legend>
	<table border="1" cellpadding="4" cellspacing="2">
		<? foreach (array('sqlite_master', 'sqlite_sequence') as $table):
			$rows = $db->count($table);
			if ($rows !== false): ?>
Ejemplo n.º 2
0
<?php

require 'inc.bootstrap.php';
requireParams('wiki');
if ($search = trim(@$_GET['search'])) {
    $response = wikia_get('Search/List', array('expand' => 1, 'limit' => 10, 'query' => $search), $error, $info);
    $results = $response['items'];
}
$_title = 'Search article';
$search and $_title .= ': ' . $search;
include 'tpl.header.php';
?>
<h1><?php 
echo html(get_wiki());
?>
</h1>

<?php 
if ($search) {
    ?>
	<h2>Results</h2>

	<ul>
		<?php 
    foreach ($results as $item) {
        ?>
			<li class="result-item">
				<div class="title">
					<a href="article.php?wiki=<?php 
        echo urlencode(get_wiki());
        ?>
Ejemplo n.º 3
0
<?php

require_once 'inc.config.php';
list($_db, $_tbl) = requireParams('db', 'tbl');
require_once 'inc.database.php';
require_once 'inc.table.php';
$iPage = max(0, (int) @$_GET['page']);
$iLimit = 200;
$iStart = $iPage * $iLimit;
$szSql = trim(@$_GET['sql'] ?: 'SELECT * FROM ' . $db->escapeAndQuoteStructure($_tbl) . ' WHERE 1 LIMIT ' . $iStart . ', ' . $iLimit);
$nocrop = (int) (!empty($_GET['nocrop']));
$flip = (int) (!empty($_GET['flip']));
$export = (int) (!empty($_GET['export']));
$arrContents = $db->fetch($szSql);
if ($arrContents) {
    $cell = function ($value, $th = false) use($export) {
        return $export ? $value : array('th' => $th, 'data' => $value);
    };
    $data = array();
    if ($flip) {
        foreach ($arrContents as $i => $row) {
            // Row delimiter row
            $data[] = array($cell('', true), $cell('# ' . ($i + 1), true));
            foreach ($row as $name => $value) {
                // One row per column
                $data[] = array($cell($name, true), $cell($value));
            }
        }
    } else {
        foreach ($arrContents as $i => $row) {
            $subdata = array();
Ejemplo n.º 4
0
<?php

require 'inc.bootstrap.php';
list(, $title) = requireParams('wiki', 'title');
$response = wiki_query(array('titles' => $title, 'prop' => 'revisions', 'rvprop' => 'content', 'rvparse' => 1), $error, $info);
if (isset($response['normalized'][0]['to'])) {
    do_redirect('article', array('wiki' => get_wiki(), 'title' => $response['normalized'][0]['to']));
    exit;
}
$page = reset($response['pages']);
$content = $page['revisions'][0]['*'];
$html = $content;
$html = preg_replace('#</?noscript>#', '', $html);
$html = preg_replace('#<(script)[\\s\\S]+?</\\1>#', '', $html);
$html = preg_replace_callback('#href="/wiki/([^"]+)#', function ($match) {
    $titles = explode('?', $match[1]);
    $title = $titles[0];
    return 'href="article.php?wiki=' . get_wiki() . '&title=' . urlencode($title);
}, $html);
// $html = preg_replace('# style=".+?"#', '', $html);
if (preg_match('#^REDIRECT (.+)$#', trim(strip_tags($html)), $match)) {
    do_redirect('article', array('wiki' => get_wiki(), 'title' => $match[1]));
    exit;
}
$_title = $title;
include 'tpl.header.php';
?>
<h1><?php 
echo html(get_wiki());
?>
</h1>