LONTE SHELL EDITION


Dashboard -*- SHOW INFO -*- HASH identify -*- Config -*- Jumping

You Are Here : /var/www/virtual/tvarditsa.org/admin/
Upload File :
Current File : /var/www/virtual/tvarditsa.org/admin/gallery.php

<?include ('../classes/pager.class.php');?>

<script language="JavaScript1.2">
function confirmDelete(theLink, confirmMsg)
{
    // Confirmation is not required in the configuration file
    if (confirmMsg == '') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }

    return is_confirmed;
}
</script>

<?function gfiles ($id_edit,$dir, $pic ,$comments1,$comments2,$comments3)
{

$_FILES['pic']=$pic;
$_POST['id_dir']=$dir;
$_POST['data']['id_edit']=$id_edit;
$_POST['data']['bg_comment']=$comments1;
$_POST['data']['en_comment']=$comments2;
$_POST['data']['ru_comment']=$comments3;

if (($_FILES['pic']['name'])!=''){
					$f=date("Y-m-d_H-i-s").'_'.$_FILES['pic']['name'];
					move_uploaded_file ( $_FILES['pic']['tmp_name'], 'pic_user/'.$f ) ;
					$_POST['data']['name_pic']=$f;

// File and new size
$filename = 'pic_user/'.$f;
$filename2 =strtoupper($filename);
$percent = 0.5;

// Get new sizes
list($width, $height) = getimagesize($filename);

if($width>=$height)
	{
	 $newwidth = 160 ;//$width * $percent;
     $newheight = ($height*160)/($width);//$height * $percent;
	}
else 
	{
	 $newheight = 120;
	 $newwidth =($width*120)/($height);
	}

// Load strtoupper
$thumb = imagecreatetruecolor($newwidth, $newheight);
if(strpos($filename2,'.JPG')) $source = imagecreatefromjpeg($filename);
if(strpos($filename2,'.JPEG')) $source = imagecreatefromjpeg($filename);
if(strpos($filename2,'.PNG')) $source = imagecreatefrompng($filename);

// Resize
@imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

// Output
$fname='./pic_thumb/'.$f; 
imagejpeg($thumb,$fname,80);
$_POST['data']['name_thumb']=$f;
					}
					
	$_POST['data']['id_dir']=$dir;
	$update3 = new Pager();
	$update3->set_condition('id='.(int)$_POST['data']['id_edit']);
	//$update3->debug=TRUE;
	$update3->update ('picgallery', $_POST['data']);

}
if( ( ($_FILES['pic']['tmp_name']!='')|| ($_POST['id_edit']!=0) ) && ($_POST['bg_comment']!='') ){
gfiles ($_POST['id_edit'], $_POST['id_dir'], $_FILES['pic'], $_POST['bg_comment'], $_POST['en_comment'],$_POST['ru_comment']);
}

//DELL DIR		

 if( (int)$_GET['id_dirdell']!=0 )
 {

		$search_p = new Pager();
	   	$search_p->set_condition("id_dir='".(int)$_GET['id_dirdell']."'");
		$_pic=$search_p->create ('picgallery','*');
		if(is_array($_pic['data']))
		foreach ($_pic['data'] as $nid => $pic_name)
			 { 
		   	    @unlink("pic_thumb/".$pic_name['name_thumb']); 
				@unlink("pic_user/".$pic_name['name_pic']); 
	 		 }
	
			$dell = new Pager();
			$dell->set_condition("id_dir='".(int)$_GET['id_dirdell']."'");
			$dell->delete ('picgallery');

		$dell_dir = new Pager();
			$dell_dir->set_condition("id='".(int)$_GET['id_dirdell']."'");
			$dell_dir->delete ('picdir');
 }
 
//dell DIR		




//dir_pic
if( ($_POST['superstar']==1) && ($_POST['add']['bg_name']!='')){

	if($_POST['id_diredit']=='')$_POST['id_diredit']=0;
	$update2 = new Pager();
	$update2->set_condition('id='.$_POST['id_diredit']);
//	$update2->debug=TRUE;
	$update2->update ('picdir', $_POST['add']);
}

if((int)$_GET['id_diredit']!=0){
	$edit_dir  = new Pager();
	$edit_dir->set_records (-1);
	$edit_dir->set_order("id DESC");
	$edit_dir->set_condition ("id=".(int)$_GET['id_diredit']);
  //$edit_dir->debug=TRUE;
    $edit_dirz = $edit_dir->create ('picdir','*');
}


//Del - pic & thumb
if((int)$_GET['thumb_dell']!=0)
{
		$user_u = new Pager();
	   	$user_u->set_condition("id='".(int)$_GET['thumb_dell']."'");
		$user_i = $user_u->create ('picgallery','*');
	if ($user_i['data'][0]['id']!='')
			{
				$dell = new Pager();
				$dell->set_condition("id='".(int)$_GET['thumb_dell']."'");
				$dell->delete ('picgallery');
				@unlink("pic_thumb/".$user_i['data'][0]['name_thumb']); 
				@unlink("pic_user/".$user_i['data'][0]['name_pic']); 
			}	
}
?>


<table  width="100%"  border="0" cellpadding="2" cellspacing="2">
<tr>
	<td width="200" valign="top">
	
 <table  width="100%"  border="0" cellpadding="0" cellspacing="0">

	<?	$dir_pic  = new Pager();
		$dir_pic->set_records (-1);
		$dir_pic->set_order("id DESC");
		//$dir_pic->debug=TRUE;
		$dirs = $dir_pic->create ('picdir','*');
		if (is_array($dirs['data']))
		foreach ($dirs['data'] as $nid => $dirs_name)
	 { ?>
  <tr>
   <td><font style="font-size: 5px;" >&nbsp;</font></td>
   <td valign="top"><img src="img/folder_cherta.gif" alt="" width="5" height="29" border="0"></td>
   <td valign="top"><a href="?lang=<?= $language; ?>&action=gallery&id_dir=<?=$dirs_name['id'];?>">
   <img src="img/folder.gif" alt="" width="23" height="23" border="0"></a></td>
  <td  valign="middle"><strong>
<a href="?lang=<?= $language; ?>&action=gallery&id_dir=<?=$dirs_name['id'];?>"><?=$dirs_name['bg_name'];?> </a>
  </strong></td>
  <td>
<a href="?lang=<?= $language; ?>&action=gallery&id_dirdell=<?=$dirs_name['id'];?>" onclick="return confirmDelete(this, 'You are about to delete folder\n\n<?= htmlspecialchars($dirs_name['bg_name'], ENT_QUOTES); ?>\n\n Are you shure?')">
<font style="font-size: 10px;">dell</a>&nbsp;<font style="font-size: 10px;" >|
<a href="?lang=<?= $language; ?>&action=gallery&id_diredit=<?=$dirs_name['id'];?>" >
<font style="font-size: 10px;" >edit</font></a></td>
  </tr>
 <? }//foreach?>
 </table>
		</td>
	<td valign="top" style="border-left: 1 solid Black;"  align="right">
<form name="adddir" method="post" action="?lang=<?= $language; ?>&action=gallery&id_dir=<?=$_GET['id_dir'];?>" enctype="multipart/form-data">
<input name="superstar" type="Hidden" value="1">
<input name="id_diredit" type="Hidden" value="<?=$_GET['id_diredit']?>">

<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-bottom: 1px solid Black;">
 <tr>
	<td width="25%">Бългаърски<br>
<input size="10"type="text" name="add[bg_name]" maxlength="250" value="<?=$edit_dirz['data'][0]['bg_name']?>" size="10"></td>
	<td width="25%">Английски<br>
<input size="10"type="text" name="add[en_name]" maxlength="250" value="<?=$edit_dirz['data'][0]['en_name']?>"></td>
	</td>
	<td width="25%">Руски<br>
<input size="10"type="text" name="add[ru_name]" maxlength="250" value="<?=$edit_dirz['data'][0]['ru_name']?>"></td>
	</td>
	<td valign="bottom" width="25%"><input size="10" type="submit" name="butona" value="<?if($_GET['id_diredit']=='')echo"добави галерия";else echo "промени глаерия"?> "></td>
 </tr></form>
</table>
	<?
if($_GET['id_dir']){
	$pic_edit  = new Pager();
	$pic_edit->set_condition ("id=".(int)$_GET['id_picedit']);
  //$pic_edit->debug=TRUE;
    $picedit = $pic_edit->create ('picgallery','*');
?>


<table border="0" cellpadding="2" cellspacing="2" width="100%" style="border-bottom: 1px solid Black;">
 <tr>
	<td valign="bottom">
<form name="addpic" method="post" action="?lang=<?= $language; ?>&action=gallery&id_dir=<?=$_GET['id_dir'];?>" enctype="multipart/form-data">
<input name="id_dir" type="Hidden" value="<?=$_GET['id_dir'];?>">
<input name="id_edit" type="Hidden" value="<?=$_GET['id_picedit'];?>">

избери картинка<br>
<input size="12" type="File" name="pic" value="Browse" size="5"></td>
<td>коментар български<br>
<input size="12" name="bg_comment" type="text" size="15"  value="<?=$picedit['data'][0]['bg_comment']?>"></td>
<td>коментар английски<br>
<input size="12" name="en_comment" type="text" size="15"  value="<?=$picedit['data'][0]['en_comment']?>"></td>
<td>коментар<br> руски<br>
<input size="12" name="ru_comment" type="text" size="15"  value="<?=$picedit['data'][0]['ru_comment']?>"></td>
<td valign="bottom"><input type="submit" name="Submit3" value="добави"></td>
</form>
</tr>
</table>	

<?
	$list_pic  = new Pager();
	$list_pic->set_records (-1);
	$list_pic->set_order("id DESC");
	$list_pic->set_condition ("id_dir=".(int)$_GET['id_dir']);
  //$list_pic->debug=TRUE;
    $tt = $list_pic->create ('picgallery','*');
}?>
<table width="100%" border="0" cellspacing="0" cellpadding="3"> 
          <tr> 
            <td  valign="top"> <?if((int)$_GET['id_dir']){
     	$c=0;
		?> 
              <table width="100%"  border="0" cellspacing="0" cellpadding="0"> 
                <?if (is_array($tt['data']))
		foreach ($tt['data'] as $nid => $tt_pic)
		 { ?> 
                <?if($c==0){?> 
                <tr> 
                  <td width="33%"  valign="top" align="center"><?include('thumb_templete.php')?></td> 
                  <?}?> 
                  <?if($c==1){?> 
                  <td width="33%"  valign="top" align="center"><?include('thumb_templete.php')?></td> 
                  <?}?> 
                  <?if($c==2){?> 
                  <td width="33%" valign="top" align="center"><?include('thumb_templete.php')?></td> 
                </tr> 
                <?}?> 
                <?
		  $c++;
		  if($c>2)$c=0;?> 
                <?} ?> 
                <?if($c==1){?> 
                <td width="33%"  valign="top">&nbsp;</td> 
                  <td width="33%"  valign="top">&nbsp;</td> 
                </tr><?}?> 
                <?if($c==2){?> 
                <td width="33%"  valign="top">&nbsp;</td> 
                  <td width="33%" valign="top">&nbsp;</td> 
                </tr><?}?> 
              </table> 
              <?}?> </td> 
          </tr> 
        </table> 
		
		


	</td>
</tr>
</table>