예제 #1
0
function blog_display_posts()
{
    global $content, $blogSettings, $data_index;
    // Declare GLOBAL variables
    $Blog = new Blog();
    // Create a new instance of the Blog class
    $slug = base64_encode(return_page_slug());
    // Determine the page we are on.
    $blogSettings = $Blog->getSettingsData();
    // Get the blog's settings
    $blog_slug = base64_encode($blogSettings["blogurl"]);
    // What page should the blog show on?
    if ($slug == $blog_slug) {
        // If we are on the page that should be showing the blog...
        $content = '';
        // Legacy support
        ob_start();
        // Create a buffer to load everything into
        switch (true) {
            // Ok, so what are we going to do?
            case isset($_GET['post']) == true:
                // Display a post
                $post_file = BLOGPOSTSFOLDER . $_GET['post'] . '.xml';
                // Get the post's XML file
                show_blog_post($post_file);
                // Show the post
                break;
            case isset($_POST['search_blog']) == true:
                // Search the blog
                search_posts($_POST['keyphrase']);
                // Search the blog with the given keyphrase
                break;
            case isset($_GET['archive']) == true:
                // View the archives
                $archive = $_GET['archive'];
                // @TODO: Redundant? Revision required...
                show_blog_archive($archive);
                // Show the requested archive
                break;
            case isset($_GET['tag']) == true:
                // Show specific post by tag
                $tag = $_GET['tag'];
                // @TODO: Redundant? Revision required...
                show_blog_tag($tag);
                // Show all posts that have the given tag
                break;
            case isset($_GET['category']) == true:
                // Show a category of posts
                $category = $_GET['category'];
                // @TODO: Redundant? Revision required...
                show_blog_category($category);
                // Show posts from the requested category
                break;
            case isset($_GET['import']):
                // RSS Auto-Importer
                auto_import();
                // Let the RSS Auto-Importer do its thing
                break;
            default:
                // None of the above?
                show_all_blog_posts();
                // Lets just show all the posts then
                break;
        }
        $content = ob_get_contents();
        // Legacy support
        ob_end_clean();
        // Output the buffer to the user.
    }
    return $content;
    // legacy support for non filter hook calls to this function
}
예제 #2
0
        <a href="index.php"><img class="icon" alt="logo" src="images/logo.png" title="link back to main page"></a>
</div>


<div class="col-md-4">

<div class="from-group">

<form class="navbar-form searchbox" role="search">
                     <div class="input-group">
                          <input type="text" class="form-control" placeholder="Search" name="term" id="srch-term">
                            <div class="input-group-btn">
                                 <button class="btn btn-default" type="submit" value="search"><span class="glyphicon glyphicon-search"></span></button>
                    <?php 
if (empty($_GET['term']) === false) {
    $search_results = search_posts($_GET['term']);
    if (empty($search_results)) {
        echo 'Your search returned no results.';
    }
    foreach ($search_results as $result) {
        echo "<h3>Results:</h3>";
        echo "<h4>{$result['title']}</h4>";
    }
}
?>
                           </div>
                     </div>
                   </form>
        
</div>                   
</div>    
예제 #3
0
        // mode 5 is map search
        die(search_maps($_GET['search']));
    }
    if ($_GET['mode'] == '4') {
        // mode 4 is wiki search
        die(search_wiki($_GET['search']));
    }
    if ($_GET['mode'] == '3') {
        // mode 3 is video search
        die(search_videos($_GET['search']));
    }
    if ($_GET['mode'] == '2') {
        // mode 2 is image search
        die(search_images($_GET['search']));
    } else {
        die(search_posts($_GET['search']));
    }
} else {
    die('No results found.');
}
// get the content excerpt
function get_excerpt($text, $length = 25)
{
    if (!$length) {
        return $text;
    }
    $text = strip_tags($text);
    $words = explode(' ', $text, $length + 1);
    if (count($words) > $length) {
        array_pop($words);
        array_push($words, '...');
<?php

ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
// set the maximal number of displayed search results here
$max_result_number = 10;
if ($_GET['s'] !== '') {
    include_once str_replace('//', '/', dirname(__FILE__) . '/') . '../../../config.php';
    include_once ROOT_DIR . '/' . INC_DIR . "/search.php";
    $result_array = array();
    $result_array = search_posts($_GET['s']);
    if (count($result_array) > 0) {
        echo '<ul id="resultlist">' . "\n";
        $result = array_slice($result_array, 0, $max_result_number);
        $size = sizeOf($result);
        for ($i = 0; $i < $size; $i++) {
            ?>
            <li class="resultlistitem">
                <a href="<?php 
            echo $result[$i]["url"];
            ?>
" rel="bookmark" title="Permanent Link: <?php 
            echo $result[$i]["url"];
            ?>
"><?php 
            echo $result[$i]["title"];
            ?>
</a>
            </li>
<?php 
        }
예제 #5
0
<?php

include 'get_connection.php';
try {
    if (PHP_SAPI === 'cli') {
        $keyword = $argv[1];
    } else {
        $keyword = $_GET['keyword'];
    }
    search_posts($conn, $keyword);
} catch (PDOException $e) {
    echo "Connection failed: " . $e->getMessage();
    return;
}
$conn = null;
function search_posts($conn, $keyword)
{
    $stmt = "SELECT id, title from posts;";
    $stmt = $conn->prepare($stmt);
    $stmt->execute();
    $results = $stmt->fetchall();
    for ($i = 0; $i < count($results); $i++) {
        if (strpos($results[$i]['title'], $keyword) !== false) {
            $to_return[$results[$i]['id']] = $results[$i]['title'];
        }
    }
    echo json_encode($to_return);
}
예제 #6
0
파일: blog.php 프로젝트: hatasu/appdroid
/** 
* Conditionals to display posts/search/archive/tags/category/importer on front end of website
* 
* @return void
*/
function blog_display_posts()
{
    global $content, $blogSettings;
    $Blog = new Blog();
    $slug = base64_encode(return_page_slug());
    $blogSettings = $Blog->getSettingsData();
    $blog_slug = base64_encode($blogSettings["blogurl"]);
    if ($slug == $blog_slug) {
        $content = '';
        ob_start();
        if ($blogSettings["displaycss"] == 'Y') {
            echo "<style>\n";
            echo $blogSettings["csscode"];
            echo "\n</style>";
        }
        switch (true) {
            case isset($_GET['post']) == true:
                $post_file = BLOGPOSTSFOLDER . $_GET['post'] . '.xml';
                show_blog_post($post_file);
                break;
            case isset($_POST['search_blog']) == true:
                search_posts($_POST['keyphrase']);
                break;
            case isset($_GET['archive']) == true:
                $archive = $_GET['archive'];
                show_blog_archive($archive);
                break;
            case isset($_GET['tag']) == true:
                $tag = $_GET['tag'];
                show_blog_tag($tag);
                break;
            case isset($_GET['category']) == true:
                $category = $_GET['category'];
                show_blog_category($category);
                break;
            case isset($_GET['import']):
                auto_import();
                break;
            default:
                show_all_blog_posts();
                break;
        }
        $content = ob_get_contents();
        ob_end_clean();
    }
    return $content;
    // legacy support for non filter hook calls to this function
}