<?php 
include("header.html");
include("config.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<title>
<?php 
echo $compname;?>
</title>
</head>
<body>
<form action="up.php" method="post" enctype="multipart/form-data"  >
<input type="file" name="image[]"/>
<input type="text" name="sari[]"/><br>
<input type="file" name="image[]"/>
<input type="text" name="sari[]"/><br>
<input type="file" name="image[]"/>
<input type="text" name="sari[]"/><br>
<input type="submit" value="upload Images" name="upload"/>
</form>
</body>
</html>
<?php 
//multiple

$page = intval($_GET['page']);
//$page = $_GET['page'];
//$page = intval($apt->get[page]);
if($page ==0) $page=1;
$end=7; 
$show=3; 
$start=$page*$end-$end; 
if($start < 0) $start=0;
session_start(); 
require_once('view_users.php');
header("Location: login.php");
//echo $_SESSION['email'];
//if ($user_id=="1"){echo '<br> hii';}
include('Thumbnail.class.php');
error_reporting(0);
$up= "upload/";
$r=0;
$max_size=120;
  $sepext = explode('.', strtolower($_FILES['image']['name'][$r]));
  $type = end($sepext);  
if ($groub_id=="1"){
header("Location: login.php");
session_start(); 
require_once('view_users.php');
  $type = end($sepext); 
/* $allow_file_type	= @explode(",",$mod->getmodsettings('file_type_Guest',$mod_name));
*/

$zize =$maxfilesize /1000000;
$dd=$maxfilesize;
$t=
explode(',',$your_city);
//$t=array('image/jpeg' , 'image/png' , 'image/gif','application/zip' , 'application/rar');
echo  $your_city,'&nbsp;',$zize,$your_name ,'<br>';
}else {
$zizee =$deleteafter /1000000;
$dd=$deleteafter;
$t=
explode(',',$your_street);
echo $your_street,'&nbsp;',$zizee,$your_name,'<br>';}
/*  if($_FILES['image']['size'][$r]> $max_size*1000) $err .= '<br/>Maximum file size must be: '. $max_size. ' KB.';
*/
if($_POST['upload']=='upload Images')
{
  while($_FILES['image']['name'][$r] != null)
   { 
  //  $type = $_FILES['image']['type'][$r];
  $fnames = $_FILES['image']['name'][$r];
$fnamess = $_FILES['image']['name'][$r];
    $fsize = $_FILES['image']['size'][$r];
    $ftype = $_FILES['image']['type'][$r];
    $ftemp = $_FILES['image']['tmp_name'][$r];
    $sari=$_POST['sari'][$r]; 
    $ext = strtolower(strrchr($fnames,'.'));
          $ext = str_replace('.','',$ext);
         $upc = in_array($ext,$t);
    if($fnames == '')
    {
        echo 'please enter a file';
    }
    elseif($fsize > $dd)
    {
        echo 'the file size is bigger than 5mb';
    }
    else if(!$upc){
 //   elseif(!in_array($ftype,$t)){
        echo 'the type of file is not allowed';
    }
    else
    {
      // if(!in_array($type, $t)) {
        if(!file_exists('upload'))
         {
           mkdir('upload','777');
         }
         $time_up = time();
  //$ddd =   new random();
$random_digit=rand(0000,9999);
$alph = "0123456789abcdefghijkLmnopqrstuvwxyz"; $code=''; for($i=0;$i<15;$i++)
{ $code .= $alph[rand(0, 35)]; }
$fname = "modules/download_center/upload/"."download_center_".$code.$time_up.$ext;
         $fnames="upload/$time_up.$code.$ext";
 $fnamess="upload/thumbs/$time_up.$code.$ext";
 $do=  move_uploaded_file($ftemp,$fnames);
 // move_uploaded_file($ftemp,$fnamess);
          $thumbss="upload/$fnamess";
if($do){
$fnamesss="$fnames";
$thefile = "$fnamesss";
if($ftype=="image/jpeg"){
$image = ImageCreateFromJPEG($thefile);
}elseif($ftype=='image/gif'){
$image = ImageCreateFromGIF($thefile);
}elseif($ftype=='image/png'){
$image = ImageCreateFromPNG($thefile);
}elseif($ftype=='image/jpg'){
$image = ImageCreateFromJPEG($thefile);
}
$width = imagesx($image) ;
$height = imagesy($image) ;
$thumb_width="150";
$new_width = $thumb_width;
$new_height="150";
//$new_height = ($new_width*$height)/ $width ;

if (function_exists('ImagecreateTrueColor'))
{
$thumbs= ImageCreateTrueColor($new_width,$new_height);
ImageCopyResampled($thumbs,$image,0,0,0,0,$new_width,$new_height,$width,$height);
}
else
{
$thumbs= ImageCreate($new_width,$new_height);
ImageCopyResized($thumbs,$image,0,0,0,0,$new_width,$new_height,$width,$height);
}
imageJPEG($thumbs,$fnamess);
imagedestroy($image);
$i++; 
}
//}
//$thumb_w="150";
//$thumb_h="150";
	/*@createthumb($ext,$fnames,$site[img_width],$site[img_high]);

/*
$site[img_width]="150";
$site[img_high]="150";
$new_w="150";
$new_h="150";
	$fileplace="$fname";
                   	@createthumb($fileplace,$ext,$fnames,$site[img_width],$site[img_high]);
*/
  $thumb=new Thumbnail("$fnames");
  $thumb->quality='100';   

$mxx="water.png";
$thumb->img_watermark='watermark.png';     
//$fnames="$up.$fnames";
$img_watermark_Hmargin=10;
$img_watermark_Vmargin=10;
//$img_watermark_Valing="TOP";
//$img_watermark_Haling="LEFT";
//$thumb->img_watermark_Valing="left";
$thumb->img_watermark_Valing="left"; 
$thumb->img_watermark_Haling="top";  
// $thumbs->process();  
          $thumb->process();   				  
      // generate image
  $thumb->save("$fnames");	
$user_id="$user_id";
$files="$fnamess";
//$sari=$sari;
 $insert_user="insert into uploaded (sari,user_id,files) VALUE ('$sari','$user_id','$files')"; 
     include("database/db_conection.php");  
   $insert_user=mysqli_query($dbcon,$insert_user);  

if ($ftype =="image/png" or $ftype=="image/jpeg" or $ftype=="image/jpg"or $ftype=="image/gif"){
echo 'Image address: <b><img width="150" src="http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\\/').'/'.$fnamess.' "/><br>';
echo '<a href="downloads.php?&filess='.$fnamess.'"</a><font>your file</font>','<br>';
}  else  {
echo  'http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\\/').'/'.$fnames.'<br>';
  
echo '<a href="downloads.php?&filess='.$fnamess.'"</a><font>your file</font>','<br>';
    }}
 $r++;
   }}
 session_start(); 
require_once('view_users.php');
if(!$_SESSION['email'])  
{      header("Location: login.php");}
   include("database/db_conection.php");   $view_users_query=mysqli_query($dbcon,$view_users_query); 
    $view_users_query="select  * from uploaded where user_id='$user_id' ORDER BY id desc Limit $start, $end";
 $nums = mysql_num_rows($view_users_query);
//select query for viewing users.  
        $run=mysqli_query($dbcon,$view_users_query);
//here run the sql query.  
  
        while($row=mysqli_fetch_array($run))
//while look to fetch the result and store in a array $row.  
        {
 $id=$row['id'];
  $sari=$row['sari'];
if(!$_SESSION['email'])  {$filesss="00";}else  {
        $filesss="$row[files]";
        //   $files="$row[files]";
	session_start();
//require_once('view_users.php');
//redirect to the login page to secure the welcome page without login access.  

echo $sari ;
echo '<a href="downloads.php?&filess='.$filesss.'"</a>','<br>',"$filesss&nbsp;";}}
//echo  $nums,'&nbsp;';
?>

<?php 
$index_middle .= "[$page]"; for ($i=$page+1 ;$i<=$lastlink ;$i++) 
 $index_middle .= "<a href=up.php?&page=$i</a>";
$link = "up.php?&page=$i"; 
// Link goes here!
echo $index_middle;
/*if ($lastlink!=1) {
$index_middle .= "<b>الصفح : </b>";}*/

//$index_middle .= "";

//$index_middle .= "</tr></table></div>";
echo  $index_middle;

if (($lastlink<=$page+$show and $page-$show>1) or ($page-$show>1) ) { $index_middle .= "<a title='الصف' href=mod.php?mod=aljazeera&modfile=aljazeera&cat=$cat&page=1> « </a> ..";} 

if ($page-$show<1) { for ($i=1 ;$i<=$page-1 ;$i++) $index_middle .= "<a href=up.php?&page=$i&page=$i</a>"; } 

if ($page-$show>=1) { for ($i=$page-$show ;$i<=$page-1 ;$i++) $index_middle .= "<a href=up.php?&page=$i</a>"; } 

if ($lastlink>$page+$show) { $index_middle .= "[$page]"; for ($i=$page+1 ;$i<=$page+$show ;$i++) { $index_middle .= "<a href=up.php?&page=$i</a>";}

$index_middle .= " .. <a title='الصفحات' href=up.php?&page=$i&page=$lastlink> » </a>"; } 

if ($lastlink<=$page+$show) { $index_middle .= "[$page]"; for ($i=$page+1 ;$i<=$lastlink ;$i++) $index_middle .= "<a href=up.php?&page=$i</a>"; } 
echo '<a href="'.$link.'">
<font size="" color="red">next</font></a>';?> 











