Beispiel #1
0
<?php

require_once __DIR__ . "/lib/comm.php";
require_once __DIR__ . "/lib/AnimGif.php";
if (check_login()) {
    header("Location:login.php");
}
ini_set('max_execution_time', 300);
$key_word = str_replace("'", "", substr(filter_input(INPUT_GET, 'kw', FILTER_SANITIZE_SPECIAL_CHARS), 0, 250));
$db = new MySQLi(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ($db->connect_error) {
    return "";
}
$sql = "select url from " . TB_PIC . generate_sub_sql($key_word) . "ORDER BY name";
$res = $db->prepare($sql);
$res->execute();
$url = null;
$res->bind_result($url);
$imgs = array();
while ($res->fetch()) {
    if ($url) {
        # 如果没有缩略图,则尝试创建。
        if (!file_exists($url . "rs")) {
            $org_img = imagecreatefromjpeg($url);
            if ($org_img) {
                list($width, $height) = getimagesize($url);
                $resize_img = imagecreatetruecolor($width * 0.25, $height * 0.25);
                imagecopyresampled($resize_img, $org_img, 0, 0, 0, 0, $width * 0.25, $height * 0.25, $width, $height);
                imagejpeg($resize_img, $url . "rs");
                imagedestroy($resize_img);
                imagedestroy($org_img);
Beispiel #2
0
function get_imgs($kw)
{
    if (strlen(trim($kw)) <= 0) {
        return "";
    }
    $db = new MySQLi(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    if ($db->connect_error) {
        return "";
    }
    $sql = "select url from " . TB_PIC . generate_sub_sql($kw) . "ORDER BY name";
    $res = $db->prepare($sql);
    $res->execute();
    $url = null;
    $res->bind_result($url);
    $img = "[ ";
    while ($res->fetch()) {
        if (file_exists($url . 'rs')) {
            $img .= '"' . $url . 'rs",';
        }
    }
    $img = substr($img, 0, strlen($img) - 1) . " ]";
    return $img;
}
Beispiel #3
0
function show_search_result($kw, $total, $pn, $size = 25)
{
    global $imgs;
    echo "<table class='table table-striped'>";
    echo "<tr><th class='text-center'>序号</th><th class='text-center'>IP</th><th class='text-center'>时间</th>";
    echo "<th class='text-center'><button id='j_del' class='btn btn-danger btn-xs' onclick='del_pics();' >删除</button>&nbsp;";
    echo "<button class='btn btn-success btn-xs' onclick='select_all();' >全选</button></tr>";
    if ($total === 0) {
        echo "</table>";
        return;
    }
    $db = new MySQLi(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    if ($db->connect_error) {
        echo "</table>";
        return;
    }
    $sql = "select ip,name,url from " . TB_PIC . generate_sub_sql($kw) . "ORDER BY name LIMIT {$pn},{$size}";
    # echo $sql;
    $res = $db->prepare($sql);
    $res->execute();
    $ip = $name = $url = null;
    $res->bind_result($ip, $name, $url);
    $count = 0;
    while ($res->fetch()) {
        $count++;
        echo "<tr>";
        echo "<td class='text-center'>{$count}</td>";
        echo "<td class='text-center'>{$ip}</td>";
        echo "<td class='text-center'><a id='j_img_{$count}' href='view.php?kw={$name}' target='_blank' title=''>";
        echo "{$name}</a></td>";
        echo "<td class='text-center' ><input type='checkbox' value='{$url}' name='j_checkbox' ></td>";
        echo "</tr>";
        $url_resize = $url . 'rs';
        if (file_exists($url_resize)) {
            $imgs .= "\$( \"#j_img_{$count}\" ).tooltip({ content: '<img src=\"{$url_resize}\" alt=\"{$name}\" width=\"280\"/>' }); \n";
        } else {
            $imgs .= "\$( \"#j_img_{$count}\" ).tooltip({ content: '<img src=\"{$url}\" alt=\"{$name}\" width=\"280\"/>' }); \n";
        }
    }
    echo "</table>";
}