<div class="filter_portfolio">
          <div class="filter_title_b">
            <div class="container">
              <div class="row">
                <div class="span12">
                  <center><h3 class="icon-desktop">&nbsp;Скриншоты выплат</h3></center>
                </div>
                <!-- span12 -->
              </div>
              <!-- row -->
            </div>
            <!-- container -->
          </div>
          <!-- filter_title -->
          <div class="the_filter">
              <div class="row">
                <div class="span12">
                  <section id="options" class="clearfix">
                    <div class="option-combo">
                      <ul id="filter" class="option-set clearfix" data-option-key="filter">
                      </ul>
                    </div>
                  </section>
                </div>
				  </div>
				    </div>
					  </div>
<?php

if(USER_LOGGED){

$can_screen=0;
$roq=mysql_query("SELECT oid FROM operations WHERE ologin='$u_login' AND osum>0 AND oback='' AND odate2!='' AND otype=2");
$rom=mysql_num_rows($roq);
if($rom>0){
$can_screen=1;
}

$vsq=mysql_query("SELECT sid FROM screens WHERE slogin='$u_login'");
if(mysql_num_rows($vsq)>=$rom){
$can_screen=2;
}

if($u_login=='admin'){
$can_screen=1;
}

// ПРИЁМ СКРИНА

$screens_warning=0;
$ww=1300;
$nh=670;

$sd=strtolower($_FILES['screens']['name']);

if($can_screen==1 && isset($_FILES['screens']['name']) && $d_screens_mode!=2 && $_SESSION['can_screen']>$time){
echo '<center>
<div class="alert alert-dismissable alert-danger">
                                 <button type="button" class="close" data-dismiss="alert">x</button>
                                 <strong>Следующий скрин можно оставить через '.($_SESSION['can_screen']-$time).' секунд</strong></div></center>';
}

if($can_screen==1 && isset($_FILES['screens']['name']) && $d_screens_mode!=2 && $_SESSION['can_screen']<$time){
$_SESSION['can_screen']=$time+$screens_t;

if($_FILES['screens']['name']!='' && ($_FILES['screens']['size']/1024)<3000 && GetImageSize($_FILES['screens']['tmp_name']) && (preg_match("/\.jpg$/",$sd) or preg_match("/\.png$/",$sd) or preg_match("/\.gif$/",$sd))) {

$s = GetImageSize( $_FILES['screens']['tmp_name'] );

/*
	$s
	Array
		(
			[0] => 500
			[1] => 446
			[2] => 2
			[3] => width="500" height="446"
			[bits] => 8
			[channels] => 3
			[mime] => image/jpeg
		)
*/

$sn = $_FILES['screens']['tmp_name'];

if($s[2]=='1'){ $p=ImageCreateFromgif($sn); }
if($s[2]=='2'){ $p=ImageCreateFromjpeg($sn); }
if($s[2]=='3'){ $p=ImageCreateFrompng($sn); }

$k=$s[0]/$ww;
$h=ceil($s[1]/$k);
if($h>$nh){
$kh=$h/$nh;
$h=$nh;
$ww=ceil($ww/$kh);
}

$d=ImageCreateTrueColor($ww,$h);
imagecopyresampled($d,$p,0,0,0,0,$ww,$h,$s[0],$s[1]);
@imagejpeg($d,'screens/'.$u_login.'_'.$time.'.jpg');
// imagejpeg($d,'screens/'.$u_login.'_'.$time.'.jpg');


imagedestroy($p);
imagedestroy($d);

mysql_query("INSERT INTO screens (slogin,sdate,scan) VALUES ('$u_login','$time','$d_screens_mode')");
if($d_screens_mode!=1){
mysql_query("UPDATE data SET screens_count=(SELECT COUNT(sid) FROM screens WHERE scan!=1)");
}
$screens_show=0;
}
else {
$screens_warning=1;
}
}

}

//  ГЕНЕРАТОР СТРАНИЦ

$s_links='';
$sc_f=1;
if(isset($_GET['pn'])){
$_GET['pn']=preg_replace('#[^0-9]+#','',$_GET['pn']);
$_GET['pn']=preg_replace('#^[0]+#','',$_GET['pn']);
if($_GET['pn']>0 && $_GET['pn']<2000){
$sc_f=$_GET['pn'];
}
}
$screensq=mysql_query("SELECT * FROM screens WHERE scan!=1");
$sc_lim=(mysql_num_rows($screensq))/$screens_pp;
if($sc_lim>1){
for($n=0;$n<$sc_lim;$n++){
if($sc_f==($n+1)){ $s_links.='<font class="screens_link_a">'.($n+1).'</font> &nbsp;'; }
else{ $s_links.='<a class="screens_link_b" href="/?page=screens&pn='.($n+1).'">'.($n+1).'</a> &nbsp;'; }
}
}
?>

<?php if(isset($screens_show) && $d_screens_mode==1){ echo '<div class="screens_premod">Ваш скрин будет доступен после одобрения администрацией</div>'; } ?>

<?php if(isset($screens_show) && $d_screens_mode==0){ echo '<div class="screens_success">Ваш скрин добавлен</div>'; } ?>

<?php
if($d_screens_mode!=2){

if(!USER_LOGGED){ echo '
<center>
<div class="alert alert-dismissable alert-danger">
                                 <strong>Чтобы добавить выплату, Вам необходимо выполнить вход в аккаунт</strong></div></center>'; }

if(USER_LOGGED && $can_screen==0){ echo '<center>
<div class="alert alert-dismissable alert-danger">
                                 <strong>Чтобы оставить скрин выплаты, Вы должны вывести средства</strong></div></center>'; }

if(USER_LOGGED && $can_screen==2){ echo '<center>
<div class="alert alert-dismissable alert-danger">
                                 <strong>Добавить скрин можно будет, когда получите выплату</strong></div></center>'; }

if(USER_LOGGED && $can_screen==1){

if($screens_warning==1){
echo '<div class="screens_warning">Скрин не загружен. Попробуйте загрузить в другом формате</strong></div></center>';
}
?>

<form id="screens_form" style="margin:0;padding:0" action="/?page=screens" method="POST" enctype="multipart/form-data">
<table align="center" class="screens_form" cellpadding="0px" cellspacing="0px">
<tr>
<td><input class="screens_input" type="file" name="screens"></td>
<td><a class="screens_button" href="javascript:with(document.getElementById('screens_form')){ submit(); }">Добавить</a></td>
</tr>
</table>
</form>

<?php
}
}
else{
echo '<div class="screens_offed">Функция добавления скринов приостановлена</div>';
}
?>


<?php if(!empty($s_links)){ echo '<div class="screens_links">'.$s_links.'</div>'; } ?>

<?php
if(!empty($_GET['pn'])){
$screen_s=preg_replace('#[^0-9]+#','',$_GET['pn']);
$screen_s=preg_replace('#^[0]+#','',$screen_s);
if($screen_s>1 && $screen_s<2000){
$screen_s=$screen_s*$screens_pp-$screens_pp;
$screensq=mysql_query("SELECT slogin,sdate FROM screens WHERE scan!=1 ORDER BY sdate DESC LIMIT $screen_s,$screens_pp");
if(mysql_num_rows($screensq)==0){
$screensq=mysql_query("SELECT slogin,sdate FROM screens WHERE scan!=1 ORDER BY sdate DESC LIMIT $screens_pp");
}
}
else {
$screensq=mysql_query("SELECT slogin,sdate FROM screens WHERE scan!=1 ORDER BY sdate DESC LIMIT $screens_pp");
}
}
else{
$screensq=mysql_query("SELECT slogin,sdate FROM screens WHERE scan!=1 ORDER BY sdate DESC LIMIT $screens_pp");
}
while($screensm=mysql_fetch_row($screensq)){ ?>
<table class="screens_table" cellpadding="0px" cellspacing="0px">
<tr>
<td class="screens_login"><?php echo $screensm[0]; ?></td>
<td class="screens_date"><?php echo date('j ',$screensm[1]).$mdate[date('n',$screensm[1])-1].date(' H:i',$screensm[1]); ?></td>
<tr><td colspan="2" class="screens_screen"><a href="screens/<?php echo $screensm[0].'_'.$screensm[1]; ?>.jpg" target="_blank"><img src="screens/<?php echo $screensm[0].'_'.$screensm[1]; ?>.jpg"></td></tr>
</tr>
</table>
<?php } ?>



<?php if(!empty($s_links)){ echo '<div class="screens_links">'.$s_links.'</div>'; } ?>
