linkoln
Active Member
- Регистрация
- 24.04.2012
- Сообщения
- 39
Думаю вы знаете что такое FaceMash если нет, то гугл в помощь.
так вот я сделал скрипт.
но тут такая проблема что левая и правая фотографии одинаковые.
если даже поменять названия у скриптов случайной выборки.
Вот посмотрите, если есть другие преложения по выборке то скажите)
в принципе мне нужен скрипт рандома изоюражений
в главную папку закиньте фотографий и все
index
Сам скрипт
так вот я сделал скрипт.
но тут такая проблема что левая и правая фотографии одинаковые.
если даже поменять названия у скриптов случайной выборки.
Вот посмотрите, если есть другие преложения по выборке то скажите)
в принципе мне нужен скрипт рандома изоюражений
в главную папку закиньте фотографий и все
index
HTML:
<!DOCTYPE HTML>
<html>
<head>
<title>FaceMash</title>
<style>
#header {
position: absolute;
width: 100%;
height: 55px;
background: #cc3838;
top:-1px;
left:-1px;
-moz-box-shadow: 0 0 10px rgba(0,0,0,0.5); /* Для Firefox */
-webkit-box-shadow: 0 0 10px rgba(0,0,0,0.5); /* Для Safari и Chrome */
box-shadow: 0 0 10px rgba(0,0,0,0.5); /* Параметры тени */
}
#FaceMash {
position: absolute;
top: 1px;
font: 35pt 'Myriad Pro';
color: #ffffff;
}
#content {
position: absolute;
top:100px;
width: 800px;
height: 200px;
left:50%;
margin-left:-400px;
}
#left {
position: absolute;
top:0px;
left:0px;
width: 246px;
height: 359px;
}
.photo {
position: absolute;
top:0px;
left:0px;
width: 246px;
height: 359px;
border: 1px solid #CCC;
-moz-box-shadow: 0 0 10px rgba(0,0,0,0.5); /* Для Firefox */
-webkit-box-shadow: 0 0 10px rgba(0,0,0,0.5); /* Для Safari и Chrome */
box-shadow: 0 0 10px rgba(0,0,0,0.5); /* Параметры тени */
}
#go {
position: absolute;
top: 372px;
left:0px;
width: inherit;
height: 36px;
background: #f6f6f6;
border: 1px solid #cccccc;
}
#go:hover {
background: #e9e8e8;
}
#go:focus {
top: 373px;
}
#right {
position: absolute;
top:0px;
right:0px;
width: 246px;
height: 359px;
}
#vs {
position: absolute;
right: 359px;
left: 359px;
top: 123px;
font: 36pt 'Myriad Pro';
color: #333333;
}
#upload {
position: absolute;
top:80px;
width: 154px;
left:-37px;
height: 31px;
background: #f6f6f6;
border: 1px solid #cccccc;
}
#upload:hover {
background: #e9e8e8;
}
</style>
</head>
<body>
<div id="header"><center><span id="FaceMash"><b>FaceMash</b></span></center></div>
<div id="content">
<div id="left">
<div class="photo"><img src="rotate.php" width="246px" height="359px"/></div>
<button id="go"><center><span style="font: 20pt 'Myriad Pro'; color: #333333; top: -2px;">Голосовать</span></center></button>
</div>
<div id="vs"><center><span><b>vs.</b></span><button id="upload"><center><span style="font: 15pt 'Myriad Pro'; color: #333333; top: -2px;">Загрузить фото</span></center></button></center></div>
<div id="right">
<div class="photo"><img src="rotate2.php" width="246px" height="359px"/></div>
<button id="go"><center><span style="font: 20pt 'Myriad Pro'; color: #333333; top: -2px;">Голосовать</span></center></button>
</div>
</div>
</body>
</html>
PHP:
<?php
/*
FaceMash
*/
/* ------------------------- CONFIGURATION -----------------------
Set $folder to the full path to the location of your images.
For example: $folder = '/user/me/example.com/images/';
If the rotate.php file will be in the same folder as your
images then you should leave it set to $folder = '.';
*/
$folder = '.';
$extList = array();
$extList['gif'] = 'image/gif';
$extList['jpg'] = 'image/jpeg';
$extList['jpeg'] = 'image/jpeg';
$extList['png'] = 'image/png';
// --------------------- END CONFIGURATION -----------------------
$img = null;
if (substr($folder,-1) != '/') {
$folder = $folder.'/';
}
if (isset($_GET['img'])) {
$imageInfo = pathinfo($_GET['img']);
if (
isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&
file_exists( $folder.$imageInfo['basename'] )
) {
$img = $folder.$imageInfo['basename'];
}
} else {
$fileList = array();
$handle = opendir($folder);
while ( false !== ( $file = readdir($handle) ) ) {
$file_info = pathinfo($file);
if (
isset( $extList[ strtolower( $file_info['extension'] ) ] )
) {
$fileList[] = $file;
}
}
closedir($handle);
if (count($fileList) > 0) {
$imageNumber = time() % count($fileList);
$img = $folder.$fileList[$imageNumber];
}
}
if ($img!=null) {
$imageInfo = pathinfo($img);
$contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
header ($contentType);
readfile($img);
} else {
if ( function_exists('imagecreate') ) {
header ("Content-type: image/png");
$im = @imagecreate (100, 100)
or die ("Cannot initialize new GD image stream");
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 0,0,0);
imagestring ($im, 2, 5, 5, "IMAGE ERROR", $text_color);
imagepng ($im);
imagedestroy($im);
}
}
?>