示例#1
0
                imagedestroy($tmp);
            }
        }
        imagejpeg($im, "../" . $outfile);
        if (!file_exists("../" . $thumbfile)) {
            $thumb = createThumb($im, 55);
            imagejpeg($thumb, "../" . $thumbfile);
        }
        $result['addToList'] = true;
        $result['thumb'] = $thumbfile;
    } else {
        // duplicate!
        $result["duplicate"] = true;
    }
    $result["name"] = $nick;
    $result["clan"] = getClanName($nick);
    $result["file"] = $outfile;
    // send the final data back as a success!
    print json_encode($result);
} else {
    print json_encode(array("error" => "error, someone didn't flip enough!"));
}
function createName($first, $middle, $last)
{
    if ($first == $middle && $middle == $last) {
        // edge case where longer names are more interesting, but
        // we want to show the real name when all three pieces are
        // one person:
        $str = $first;
    } else {
        // break each name into thirds, then return the mashup name
示例#2
0
function thumbnails()
{
    $files = array();
    $str = "";
    $dir = opendir('./cache/');
    while (false !== ($filename = readdir($dir))) {
        if ($filename[0] !== ".") {
            $files[] = substr($filename, 0, strlen($filename) - 4);
        }
    }
    // generate a list of "last names" from the images
    $clans = array();
    foreach ($files as $file) {
        $clan = getClanName($file);
        if (empty($clans[$clan])) {
            $clans[$clan] = array();
        }
        $clans[$clan][] = $file;
    }
    // put each thumbnail into an UL by clan name
    foreach ($clans as $clan => $data) {
        print "<div id='" . $clan . "' class='clan'>";
        print "<h2><a href='#" . $clan . "'>" . $clan . "</a></h2>";
        print "<ul class='" . $clan . "'>";
        foreach ($data as $file) {
            print "\n\t\t<li class='thumbnail'><a href='cache/" . $file . ".jpg' title='" . $file . "' class='imageThumb'>" . "<img src='cache/." . $file . "_thumb.jpg'>" . "</a></li>";
        }
        print "</ul>";
        print "</div>";
    }
}