예제 #1
0
파일: index.php 프로젝트: kelsh/classic
# Image
session_start();
include_once 'template.php';
include_once 'mysql.php';
include_once 'functions.php';
$Vowels = array('a', 'e', 'i', 'o', 'u');
shuffle($Vowels);
$Blog = "Bl{$Vowels[0]}g";
$TotalQuery = mysql_query("Select `ID` from `Images` order by `ID` desc limit 1");
list($Total) = mysql_fetch_array($TotalQuery);
$RandomID = rand(1, $Total);
while ($_SESSION['Seen'][$RandomID]) {
    if ($Total <= count($_SESSION['Seen'])) {
        unset($_SESSION['Seen']);
    }
    $RandomID = rand(1, $Total);
}
$_SESSION['Seen'][$RandomID] = true;
$RandomQuery = mysql_query("Select `URL`, `Caption`, `Permalink` from `Images` where `ID`='{$RandomID}'");
list($URL, $Caption, $Permalink) = mysql_fetch_array($RandomQuery);
$Title = "<a href='/view/{$RandomID}/{$Permalink}/'>{$Caption}</a>";
$Image = "{$URL}";
$Time = time();
$Content = "<center><a href='/'><img src='{$Image}' /></a></center>";
$Extra = "<a href='{$Image}' target='_blank'>View Full Size</a>";
$Tags = DisplayTags($RandomID);
echo Template('template.html');
?>


예제 #2
0
파일: view.php 프로젝트: kelsh/classic
    echo "<center><a href='/'><img src='{$Image}' /></a></center>";
    $Extra = "<a href='{$Image}' target='_blank'>View Full Size</a>";
    $Tags = DisplayTags($Redirect[1]);
} elseif (empty($Redirect[1])) {
    $Tags = DisplayAllTags();
} else {
    $Tag = filter_var(str_replace('-', ' ', $Redirect[1]), FILTER_SANITIZE_SPECIAL_CHARS);
    $CountQuery = mysql_query("Select `ID` from `Tags` where `Name`='{$Tag}'");
    $ImageCount = mysql_num_rows($CountQuery);
    $RandomOffset = rand(0, $ImageCount - 1);
    #echo "Count: $ImageCount<br />";
    #echo "Seen: ".count($_SESSION[$Tag]['Seen'])."<br />";
    while ($_SESSION[$Tag]['Seen'][$RandomOffset]) {
        if ($ImageCount - 1 <= count($_SESSION[$Tag]['Seen'])) {
            unset($_SESSION[$Tag]);
        }
        $RandomOffset = rand(0, $ImageCount - 1);
    }
    $_SESSION[$Tag]['Seen'][$RandomOffset] = true;
    $RandomQuery = mysql_query("Select `Image` from `Tags` where `Name`='{$Tag}' limit {$RandomOffset}, 1");
    list($ImageID) = mysql_fetch_array($RandomQuery);
    $ImageQuery = mysql_query("Select `URL`, `Caption`, `Permalink` from `Images` where `ID`='{$ImageID}'");
    list($URL, $Caption, $Permalink) = mysql_fetch_array($ImageQuery);
    $Title = "<a href='/view/{$ImageID}/{$Permalink}/'>{$Caption}</a>";
    $Image = "{$URL}";
    $TagPermalink = Permalink($Tag);
    echo "<center><a href='/view/{$TagPermalink}/'><img src='{$Image}' /></a></center>";
    $Extra = "<a href='{$Image}' target='_blank'>View Full Size</a>";
    $Tags = DisplayTags($ImageID);
    #echo "Displaying a random image from tag: $Tag ($ImageCount)";
}