Exemplo n.º 1
0
function getPage()
{
    $page = checkPage();
    $db = new db();
    $db->connect();
    $pageData = getPageData($page);
    if (count($pageData) <= 1) {
        $pageData = getPageData("404");
        header("HTTP/1.1 404 Not Found");
    }
    sendPage($pageData);
}
Exemplo n.º 2
0
function getTitle($url)
{
    $pagedata = getPageData($url);
    if ($pagedata) {
        $page = new DomDocument();
        libxml_use_internal_errors(true);
        $page->loadHTML($pagedata);
        $titleDom = $page->getelementsbytagname('title');
        if ($titleDom->length > 0) {
            $title = $titleDom->item(0)->textContent;
        }
        // fall back if first tag it finds is null cause... apparently that's a thing occasionally from testing
        if ($title == null) {
            if ($titleDom->length > 1) {
                $title = $titleDom->item(1)->textContent;
            }
        }
        return $title;
    } else {
        return 'no data recieved';
    }
}
Exemplo n.º 3
0
<?php

if (!file_exists("site_config.xml")) {
    header('Location: admin/');
} else {
    include 'site_variables.php';
    include 'functions.php';
    $page_data = array();
    $locatn = '';
    $locatn = $global_site['folder'] . 'pages/data/menu_tabs';
    $page_data['menu_tabs'] = getMenuTabs($locatn);
    $locatn = $global_site['folder'] . 'pages/data/panel';
    $page_data['panel'] = getPanelData($locatn);
    if (isset($_GET['page']) && $_GET['page'] != NULL) {
        $locatn = $global_site['folder'] . 'pages/data/pg_' . $_GET['page'];
    } else {
        $locatn = $global_site['folder'] . 'pages/data/pg_Home';
    }
    $temp_data = getPageData($locatn);
    $page_data['title'] = $temp_data['pg_title'];
    $page_data['contents'] = $temp_data['pg_contents'];
    include $global_site['folder'] . 'themes/' . $global_site['theme'] . '/template.php';
}
Exemplo n.º 4
0
<?php

if (isset($_POST['page_name'])) {
    getPageData($_POST['page_name']);
}
function connectToDB()
{
    $mysqliLink = new mysqli('localhost', 'root', 'root', 'test_db');
    if (mysqli_connect_errno()) {
        exit;
    }
    return $mysqliLink;
}
function getPageData($pageName)
{
    $mysqliLink = connectToDB();
    $query = $mysqliLink->query("SELECT * FROM page_data WHERE page_name = '{$pageName}'");
    $title = "";
    $desc = "";
    if ($row = $query->fetch_object()) {
        $title = $row->page_title;
        $desc = $row->page_desc;
    }
    $html = '<h1>' . $title . '</h1>';
    $html .= '<p>' . $desc . '</p>';
    echo $html;
}