<?php
session_start();/**************************************************صفحة تحميل المزيد من الصور*******************************************************************/

// ضبط اعدادات اللغة العربية للصفحة 
header("content-type:text/html;charset=utf-8"); 


//استدعاء ملف الاعدادات
$conc_type='cp_exec_conc';
include '../conf.php';
include '../conf_sub.php';

//تحديد لينك الموقع
$_SESSION['website_url'] = $website_url;
//استدعاء ملف الاتصال بقاعدة البيانات
//include $cp_exec_conc;

//استدعاء ملف الحماية من الحقن
include "../injection.php";


//ضمان توافق قاعدة البيانات مع اللغة العربية
mysqli_query($conn,"SET NAMES 'utf8'");
mysqli_query($conn,'SET CHARACTER SET utf8');
mysqli_query($conn,"SET character_set_client=utf8");
mysqli_query($conn,"SET character_set_connection=utf8");
mysqli_query($conn,"SET character_set_database=utf8");
mysqli_query($conn,"SET character_set_results=utf8");
mysqli_query($conn,"SET character_set_server=utf8");
mysqli_query($conn," set character_set_server='utf8'");
include("fetch_array_search.php");

//ايقاف التنفيذ فى حالة عدم تسجيل الدخول
if(!isset($_SESSION[$domain.'_user']) || $_SESSION[$domain.'_user']==""){die;}

if(!isset($_POST['table']) || !isset($_POST['start']) || !isset($_POST['end']) || 
!isset($_POST['num_rows']) || !isset($_POST['cat']) ||!isset($_POST['search'])){ die(); };


// معالجة حقن المتغيرات
injection($_POST['search']);
injection($_POST['table']);
is_num($_POST['start']);
is_num($_POST['end']);
is_num($_POST['num_rows']);
injection($_POST['cat']);



/*  اسم الجدول وبداية الكويرى */  
$table=$_POST['table'];

//رقم سحل البداية
$start=$_POST['start'];

//رقم سحل النهاية
$end=$_POST['end'];

// عدد الصفوف المستدعاة

//تحديد عدد الصفوف
$num_rows=$_POST['num_rows'];

// القسم الحالى
$cat=$_POST['cat'];

// كلمة البحث
$search=$_POST['search'];
$comp=$_POST['comp'];

$depart='';	
if($_POST['depart']=="0"){
$depart='';	
}else{

// القسم
$depart=$_POST['depart'];	
}


//بداية الاستعلام
$query="select  sort,created,modified,user_created,user_modified,active,images,id,title,date,priority  from $table where title like '%$search%'  order by `priority` desc , `sort` desc , id desc 
 limit $start,$num_rows ";


//تنفيذ الاستعلام
$result=mysqli_query($conn,$query);
$rows_num=mysqli_num_rows($result);

?>	

<div id="load_wait"></div>

<div id="result_view">
	
<table   cellpadding="0" cellspacing="0" width="988"  dir="rtl"  style="border-left:solid 1px #ccc" >
<tr class='first_table_tr'>
<td align="center" width='20'>الصورة</td>
<td align="center">العنوان</td>

<td width='100' align="center" >التاريخ</td>
<td width='5' align="center">رابط</td>
<td width='5' align="center">الاولوية</td>
<td width='5' align="center">النشر</td>
<td width="15" align="center">ترتيب</td>
<td width="15" align="center">تعديل</td>
<td width="15" align="center">تفاصيل</td>	
<td width="15" align="center">حذف</td>
</tr>	
	
	
<?php
   /*بداية التكرار */  
 while($fetch = mysqli_fetch_array($result)) {
   		 $fetch = clean_array($fetch);
	
//$event_date=explode("-",$fetch['date']);

     
  
   /*استخراج جميع الصور*/  
  $current_image=explode(",",$fetch['images']);
if (array_key_exists(1,$current_image)){

     
  
   /*استخراج الصورة الاساسية*/  
  $current_image=explode(".",$current_image[1]);	
}	
	
echo"<tr tr_id='$fetch[id]' priority='$fetch[priority]' arrang='$fetch[sort]' id='tr$fetch[id]' class='table_tr'>";
echo"<td align='center'>
<img loading='lazy' class='view_image' width='25' height='25'  src='../img/$table/$current_image[0]_tiny.webp?time='".time()."/>
</td>";
echo"<td><div>$fetch[title]</div></td>";
echo"<td align='center'><div>$fetch[date]</div></td>";


echo"<td align='center'>
<a target='_blank' href='$_SESSION[website_url]/gallery/$fetch[id]/$fetch[title]' >
<img loading='lazy' width='25' height='25'  src='../img/url.png' />
</a>
</td>";


echo"<td align='center'><a class='priority_multi' alt='$fetch[id]' table='$table' >";
if($fetch['priority']=='1'){
echo"<img loading='lazy' table='$table' id='priority_image$fetch[id]' class='priority_image' src='../img/priority.png'></td>";	
}else{
echo"<img loading='lazy' table='$table' id='priority_image$fetch[id]' class='priority_image' src='../img/not_priority.png'></td>";		
}


echo"<td align='center'><a class='active_multi' alt='$fetch[id]' table='$table' >";
if($fetch['active']=='1'){
echo"<img loading='lazy' table='$table' id='active_image$fetch[id]' class='active_image' src='../img/active.png' status='1'></a></td>";	
}else{
echo"<img loading='lazy' table='$table' id='active_image$fetch[id]' class='active_image' src='../img/not_active.png' status='1'></a></td>";		
}

echo"<td align='center'>";
?>
<div tr_id="<?php echo $fetch['id']?>" arrang="<?php echo $fetch['sort']?>" priority="<?php echo $fetch['priority']?>" class="up_arrow"></div>
<div tr_id="<?php echo $fetch['id']?>" arrang="<?php echo $fetch['sort']?>" priority="<?php echo $fetch['priority']?>" class="down_arrow"></div>

<?php
echo"</td>"; 
echo"<td align='center'><a class='edit_galleries' alt'$fetch[id]' href='edit_galleries.php?id=$fetch[id]'><img loading='lazy' a src='../img/edit.png'></td>";
echo"<td align='center'><a table='$table' class='show_details' created='$fetch[created]' modified='$fetch[modified]' user_created='$fetch[user_created]' user_modified='$fetch[user_modified]'  alt='$fetch[id]'><img loading='lazy' src='../img/details.png'></td>";

echo"<td align='center'><a class='delete' alt='$fetch[id]'><img loading='lazy' src='../img/delete.png'></td>";
echo"</tr>";
}	
?>
</table>
</div>
<div style='display:none' id='done_load'>done</div>		
		


