<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?php

/**
 * @author Hossam
 * @copyright 2011
 */
require_once("../lib/func_ar.php");



//------------------------------------ name admin to cookies --------------------------------

    $sel = "select user from users where adm_mem=1";
        $query = mysql_query($sel);
        while($result=mysql_fetch_array($query)){
            extract($result);
            $admin=$user;
        }

//------------------------------------ name site--------------------------------
function namesite(){
    $sel = "select * from users where adm_mem=1";
        $query = mysql_query($sel);
        while($result=mysql_fetch_array($query)){
            extract($result);
            echo $sitename;
        }
}
//------------------------------------ acount new message--------------------------------
function name_user(){
    $sel = "select name from users where adm_mem=1";
        $query = mysql_query($sel);
        while($result=mysql_fetch_array($query)){
            extract($result);
            echo $name;
        }
}


//--------------------------------- select active or not active -------------------------------------------
function active(){
    echo "<option value='1'>تفعيل</option>";
    echo "<option value='0'>الغاء التفعيل</option>";
}

//////////////////////////// fetch table father_mali to select option///////////////////////

function sel_father_mali(){
    $sel = "select * from cat_mali where langu='en'";
    $query = mysql_query($sel);
    while($result = mysql_fetch_array($query)){
        extract($result);
        echo "
            <option value='$id'>$name</option>
        ";
    }
}

//////////////////////////// fetch table father_mali to select option///////////////////////

function sel_father_maktaba(){
    $sel = "select * from cat_maktaba where langu='en'";
    $query = mysql_query($sel);
    while($result = mysql_fetch_array($query)){
        extract($result);
        echo "
            <option value='$id'>$name</option>
        ";
    }
}
//////////////////////////// fetch table father to select option///////////////////////

function sel_father(){
    $sel = "select * from cat where langu='en'";
    $query = mysql_query($sel);
    while($result = mysql_fetch_array($query)){
        extract($result);
        echo "
            <option value='$id'>$name</option>
        ";
    }
}

//------------------------------------ acount new message--------------------------------
function acount_new_message(){
    $sel = "select * from message where status=0";
        $query = mysql_query($sel);
        $resultrow = mysql_num_rows($query);
        echo $resultrow;
}


//--------------------------------- ahow all message  -------------------------------------------
/*
function message(){
    $sel = "select * from message";
        $query = mysql_query($sel);
        $resultrow = mysql_num_rows($query);
        //في حالة وجد بيانات
        if($resultrow > 0){

            ///pagenation step 1 $each_page
            $qury="select * from pagenation where id=1";
            $resul=mysql_query($qury);
            while($res = mysql_fetch_array($resul)){
                extract($res);
            }
            $each_page=$message;
            ///pagenation step 2 $post_count
            $qury="select * from message";
            $resul=mysql_query($qury);
            $post_count=mysql_num_rows($resul);
            ///pagenation step 3 $page_count
            $page_count=ceil($post_count/$each_page);
            ///pagenation step 4 $page
            if(!isset($_GET['page']) || intval($_GET['page']) <=0){
                $page=1;
            }elseif($_GET['page'] > $page_count){
                $page=$page_count;
            }else{
                $page=$_GET['page'];
            }
            ///pagenation step 5 $start
            if($post_count >0){
                $start=$each_page*($page-1);
            }


            $self = $_SERVER['PHP_SELF'];
            echo "<form action='$self' method='post'>";
                echo "<table>";
                    echo "<th class='th_table'>حذف</th>";
                    echo "<th class='th_table'>الراسل</th>";
                    echo "<th class='th_table'>الشركة</th>";



                    echo "<th class='th_table'>تاريخ الارسال</th>";
                    echo "<th class='th_table'>الحالة</th>";
                    echo "<th class='th_table'>عرض</th>";

                ///pagenation step 6 fetch data from db
                $sel3="select * from message ORDER BY date_time DESC limit $each_page OFFSET $start";
                $qur3=mysql_query($sel3);
                while($result3=mysql_fetch_array($qur3)){
                    extract($result3);
                    $idd = $id;

                    $contentmsg=substr($content, 0, 5);
                    $mailmsg=substr($mail, 0, 5);
                    $telmsg=substr($tel, 0, 5);
                    $companymsg=substr($company, 0, 5);
                    $namemsg=substr($name, 0, 5);

                    //ÇáÑÓÇáÉ ãÞÑæÁÉ Çã áÇ
                    if($status==0){
                        $status="<font color='red'>غير مقروء</font>";
                    }else{$status="<font color='green'>مقروء</font>";}
                    if($idd%2 != 0){
                        $color="bg1";
                    }else{$color="bg2";}
                    echo "<tr class='$color'>";
                        echo "<td align='center'><input type='checkbox' value='$idd' name='id[]' /><img src='images/1122.png' title='Delete' width='24' height='24' /></td>";
                        echo "<td>$namemsg...</td>";
                        echo "<td>$companymsg...</td>";

                        echo "<td align='center'>$date_time</td>";
                        echo "<td align='center'>$status</td>";
                        echo "<td align='center'><a href='message_in.php?id=$id'><img src='images/21.png' title='Show' width='32' height='32' /></a></td>";
                    echo "</tr>";

                }
                echo "<tr>";
                        echo "<td><input class='submit' type='submit' name='delete' value='Delete' /></td>";
                        echo "<td></td>";
                        echo "<td></td>";

                        echo "<td></td>";
                        echo "<td></td>";
                        echo "<td></td>";
                    echo "</tr>";
                echo "</table>";
            echo "</form>";
    ///////////////////////////////////////////////
            //delete message
            $delete=$_POST['delete'];
            $id=$_POST['id'];
            if($delete){
                if($id>0){
                    foreach($id as $one_by_one){
                    $query_delete_message=mysql_query('delete from message where id ='.$one_by_one.'');
                        if($query_delete_message){
                            echo "من فضلك انتظر حتى يتم الحذف <img src='images/loading11.gif' />".
                                        "<meta http-equiv='refresh' content='5'>";
                        }
                    }
                }else{echo "<font color='red'>من فضلك إختر رسالة لحذفها!!!";}
            }
   /////////////////////////////////////////////
            ///pagenation step 7 design button counter
            echo "<div class='counter'>";
                echo "<div align='right'><font color='aqu'>إجمالي عدد الرسائل : $post_count</font></div>";
                if($page_count > 1){
                                $first = 1;
                                $prev = $page - 1;
                                $next = $page + 1;
                                $last = $page_count;

                                //show first & prev
                                if($page > 1){
                                    echo ' <a href="message.php?page='.$first.'">الأول</a> ';
                                    echo ' <a href="message.php?page='.$prev.'">السابق</a> ';
                                }

                                // show numbers pages
                                for($i=1; $i<=$page_count; $i++){
                                    if($page != $i){
                                        echo ' <a href="message.php?page='.$i.'">'.$i.'</a> ';
                                    }else{
                                        echo '<b>'.$i.'</b>';
                                    }

                                }

                                //show next & last
                                if($page < $page_count){
                                    echo ' <a href="message.php?page='.$next.'">التالي</a> ';
                                    echo ' <a href="message.php?page='.$last.'">الأخير</a> ';
                                }

                }


            echo "</div>";
                    ///////////////////////////
                    //counter view pagenation
                    echo "<span class='view'>
                        <form action='$self' method='post'>
                            <input type='submit' name='submitview' value='عرض' />
                            <input type='text' value='$each_page' size='1' name='view' /> سجل في الصفحة
                        </form>
                    </span>";
                    $submitview = $_POST['submitview'];
                    $view = $_POST['view'];
                    if($submitview){
                        //when text 0 or text
                        if(!isset($view) || intval($view) <=0){
                            $view=5;
                        }

                        $update="update pagenation set message='$view' where id=1";
                        $qu=mysql_query($update);
                        echo "<meta http-equiv='refresh' content='1'>";
                    }
                    ///////////////////////////
        }else{
            //في حالة لم يجد بيانات
            echo "<font color='green'>لا توجد رسائل</font>";
        }
}
*/

///////////////////////////// edit father_mali ////////////////////////////////////////////////////////////

function edit_father_mali(){
    $show=$_POST['show'];

        //Ýí ÍÇáÉ ÇáÊÍãíá ÊáÞÇÆí ááÕÝÍÉ íÚÑÖ ÇáãäÊÌÇÊ ßáåÇ
        $sel = "select * from cat_mali where langu='en'";
        $query = mysql_query($sel);
        $resultrow = mysql_num_rows($query);
        //في حالة وجد بيانات
        if($resultrow > 0){
            /*pagenation step 1 $each_page*/
            $qury="select * from pagenation where id=1";
            $resul=mysql_query($qury);
            while($res = mysql_fetch_array($resul)){
                extract($res);
            }
            $each_page=$father_mali;
            /*pagenation step 2 $post_count*/
            $qury="select * from cat_mali where langu='en'";
            $resul=mysql_query($qury);
            $post_count=mysql_num_rows($resul);
            /*pagenation step 3 $page_count*/
            $page_count=ceil($post_count/$each_page);
            /*pagenation step 4 $page*/
            if(!isset($_GET['page']) || intval($_GET['page']) <=0){
                $page=1;
            }elseif($_GET['page'] > $page_count){
                $page=$page_count;
            }else{
                $page=$_GET['page'];
            }
            /*pagenation step 5 $start*/
            if($post_count >0){
                $start=$each_page*($page-1);
            }

                    ///////////////////////////////////////////////
                    //delete father
                    $delete=$_POST['delete'];
                    $id=$_POST['id'];
                    if($delete){
                        if($id>0){
                            foreach($id as $one_by_one){
                            $query_delete_message=mysql_query('delete from cat_mali where id ='.$one_by_one.'');
                                if($query_delete_message){
                                    echo "من فضلك انتظر حتى يتم الحذف <img src='images/loading21.gif' />".
                                        "<meta http-equiv='refresh' content='5'>";
                                }
                            }
                        }else{echo "<font color='red'>من فضلك اختر قسم لحذفه!!!";}
                    }
                    /////////////////////////////////////////////

        $self = $_SERVER['PHP_SELF'];
        echo "<form action='$self' method='post'>";
            echo "<table>";

                echo "<th class='th_table'>اسم القسم</th>";
                echo "<th class='th_table'>تعديل</th>";
                echo "<th class='th_table'>الحالة</th>";
                echo "<th class='th_table'>delete</th>";
            /*pagenation step 6 fetch data from db*/
                $sel = "select * from cat_mali where langu='en' ORDER BY date_time DESC limit $each_page OFFSET $start";
                $query = mysql_query($sel);
                while($result = mysql_fetch_array($query)){
                    extract($result);

                    $idd = $id;
                            //change pic when active or not active
                             if($active != 0){
                                $picchange = "<img src='images/apply1.png' width='23' height='23' title='un active' />";
                             }else{
                                $picchange = "<img src='images/apply.png' width='23' height='23' title='active' />";
                             }
                             if($idd%2 != 0){
                                $color="bg1";
                             }else{$color="bg2";}
                    echo "<tr class='$color'>";
                        echo "<td class='td_table'>$name</td>";
                        echo "<td align='center'>
                                <a href='edit_father_in_mali.php?id=$idd'><img src='images/edi.png' width='23' height='23' title='Edit' /></a>
                              </td>";

                        echo "<td align='center'><a href='activeationfather_mali.php?id=$idd'>$picchange</a></td>";
                        echo "<td align='center'><input type='checkbox' value='$idd' name='id[]' /><img src='images/1122.png' width='23' height='23' title='Mark select to delete' /></td>";
                    echo "</tr>";
                }
                echo "<tr>";
                    echo "<td></td>";
                    echo "<td></td>";
                    echo "<td></td>";
                    echo "<td><input class='submit' type='submit' name='delete' value='Delete' /></td>";
                echo "</tr>";
            echo "</table>";
        echo "</form>";

              /*pagenation step 7 design button counter*/
            echo "<div class='counter'>";
                echo "<div align='right'><font color='aqu'>إجمالي عدد الأقسام : $post_count</font></div>";
                if($page_count > 1){
                                $first = 1;
                                $prev = $page - 1;
                                $next = $page + 1;
                                $last = $page_count;

                                //show first & prev
                                if($page > 1){
                                    echo ' <a href="edit_father_mali.php?page='.$first.'">الأول</a> ';
                                    echo ' <a href="edit_father_mali.php?page='.$prev.'">السابق</a> ';
                                }

                                // show numbers pages
                                for($i=1; $i<=$page_count; $i++){
                                    if($page != $i){
                                        echo ' <a href="edit_father_mali.php?page='.$i.'">'.$i.'</a> ';
                                    }else{
                                        echo '<b>'.$i.'</b>';
                                    }

                                }

                                //show next & last
                                if($page < $page_count){
                                    echo ' <a href="edit_father_mali.php?page='.$next.'">التالي</a> ';
                                    echo ' <a href="edit_father_mali.php?page='.$last.'">الأخير</a> ';
                                }

                }


            echo "</div>";
                    ///////////////////////////
                    //counter view pagenation
                    echo "<span class='view'>
                        <form action='$self' method='post'>
                            <input type='submit' name='submitview' value='عرض' />
                            <input type='text' value='$each_page' size='1' name='view' /> سجل في الصفحة
                        </form>
                    </span>";
                    $submitview = $_POST['submitview'];
                    $view = $_POST['view'];
                    if($submitview){
                        //when text 0 or text
                        if(!isset($view) || intval($view) <=0){
                            $view=5;
                        }

                        $update="update pagenation set father_mali='$view' where id=1";
                        $qu=mysql_query($update);
                        echo "<meta http-equiv='refresh' content='1'>";
                    }
                    ///////////////////////////

        }else{
            //في حالة لم يجد منتجات
            echo "<font color='green'>لا يوجد سجلات</font>";
        }

}

///////////////////////////// edit father_maktaba ////////////////////////////////////////////////////////////

function edit_father_maktaba(){
    $show=$_POST['show'];

        //Ýí ÍÇáÉ ÇáÊÍãíá ÊáÞÇÆí ááÕÝÍÉ íÚÑÖ ÇáãäÊÌÇÊ ßáåÇ
        $sel = "select * from cat_maktaba where langu='en'";
        $query = mysql_query($sel);
        $resultrow = mysql_num_rows($query);
        //في حالة وجد بيانات
        if($resultrow > 0){
            /*pagenation step 1 $each_page*/
            $qury="select * from pagenation where id=1";
            $resul=mysql_query($qury);
            while($res = mysql_fetch_array($resul)){
                extract($res);
            }
            $each_page=$father_maktaba;
            /*pagenation step 2 $post_count*/
            $qury="select * from cat_maktaba where langu='en'";
            $resul=mysql_query($qury);
            $post_count=mysql_num_rows($resul);
            /*pagenation step 3 $page_count*/
            $page_count=ceil($post_count/$each_page);
            /*pagenation step 4 $page*/
            if(!isset($_GET['page']) || intval($_GET['page']) <=0){
                $page=1;
            }elseif($_GET['page'] > $page_count){
                $page=$page_count;
            }else{
                $page=$_GET['page'];
            }
            /*pagenation step 5 $start*/
            if($post_count >0){
                $start=$each_page*($page-1);
            }

                    ///////////////////////////////////////////////
                    //delete father
                    $delete=$_POST['delete'];
                    $id=$_POST['id'];
                    if($delete){
                        if($id>0){
                            foreach($id as $one_by_one){
                            $query_delete_message=mysql_query('delete from cat_maktaba where id ='.$one_by_one.'');
                                if($query_delete_message){
                                    echo "من فضلك انتظر حتى يتم الحذف <img src='images/loading21.gif' />".
                                        "<meta http-equiv='refresh' content='5'>";
                                }
                            }
                        }else{echo "<font color='red'>من فضلك اختر قسم لحذفه!!!";}
                    }
                    /////////////////////////////////////////////

        $self = $_SERVER['PHP_SELF'];
        echo "<form action='$self' method='post'>";
            echo "<table>";

                echo "<th class='th_table'>اسم القسم</th>";
                echo "<th class='th_table'>تعديل</th>";
                echo "<th class='th_table'>الحالة</th>";
                echo "<th class='th_table'>delete</th>";
            /*pagenation step 6 fetch data from db*/
                $sel = "select * from cat_maktaba where langu='en' ORDER BY date_time DESC limit $each_page OFFSET $start";
                $query = mysql_query($sel);
                while($result = mysql_fetch_array($query)){
                    extract($result);

                    $idd = $id;
                            //change pic when active or not active
                             if($active != 0){
                                $picchange = "<img src='images/apply1.png' width='23' height='23' title='un active' />";
                             }else{
                                $picchange = "<img src='images/apply.png' width='23' height='23' title='active' />";
                             }
                             if($idd%2 != 0){
                                $color="bg1";
                             }else{$color="bg2";}
                    echo "<tr class='$color'>";
                        echo "<td class='td_table'>$name</td>";
                        echo "<td align='center'>
                                <a href='edit_father_in_maktaba.php?id=$idd'><img src='images/edi.png' width='23' height='23' title='Edit' /></a>
                              </td>";

                        echo "<td align='center'><a href='activeationfather_maktaba.php?id=$idd'>$picchange</a></td>";
                        echo "<td align='center'><input type='checkbox' value='$idd' name='id[]' /><img src='images/1122.png' width='23' height='23' title='Mark select to delete' /></td>";
                    echo "</tr>";
                }
                echo "<tr>";
                    echo "<td></td>";
                    echo "<td></td>";
                    echo "<td></td>";
                    echo "<td><input class='submit' type='submit' name='delete' value='Delete' /></td>";
                echo "</tr>";
            echo "</table>";
        echo "</form>";

              /*pagenation step 7 design button counter*/
            echo "<div class='counter'>";
                echo "<div align='right'><font color='aqu'>إجمالي عدد الأقسام : $post_count</font></div>";
                if($page_count > 1){
                                $first = 1;
                                $prev = $page - 1;
                                $next = $page + 1;
                                $last = $page_count;

                                //show first & prev
                                if($page > 1){
                                    echo ' <a href="edit_father_maktaba.php?page='.$first.'">الأول</a> ';
                                    echo ' <a href="edit_father_maktaba.php?page='.$prev.'">السابق</a> ';
                                }

                                // show numbers pages
                                for($i=1; $i<=$page_count; $i++){
                                    if($page != $i){
                                        echo ' <a href="edit_father_maktaba.php?page='.$i.'">'.$i.'</a> ';
                                    }else{
                                        echo '<b>'.$i.'</b>';
                                    }

                                }

                                //show next & last
                                if($page < $page_count){
                                    echo ' <a href="edit_father_maktaba.php?page='.$next.'">التالي</a> ';
                                    echo ' <a href="edit_father_maktaba.php?page='.$last.'">الأخير</a> ';
                                }

                }


            echo "</div>";
                    ///////////////////////////
                    //counter view pagenation
                    echo "<span class='view'>
                        <form action='$self' method='post'>
                            <input type='submit' name='submitview' value='عرض' />
                            <input type='text' value='$each_page' size='1' name='view' /> سجل في الصفحة
                        </form>
                    </span>";
                    $submitview = $_POST['submitview'];
                    $view = $_POST['view'];
                    if($submitview){
                        //when text 0 or text
                        if(!isset($view) || intval($view) <=0){
                            $view=5;
                        }

                        $update="update pagenation set father_maktaba='$view' where id=1";
                        $qu=mysql_query($update);
                        echo "<meta http-equiv='refresh' content='1'>";
                    }
                    ///////////////////////////

        }else{
            //في حالة لم يجد منتجات
            echo "<font color='green'>لا يوجد سجلات</font>";
        }

}



///////////////////////////// Edit son /////////////////////////////////////////////////////////////////
function edit_son_mali(){
    $show=$_POST['show'];
    $sdiv=$_POST['sdiv'];

                    ///////////////////////////////////////////////
                    //delete news
                    $delete=$_POST['delete'];
                    $id=$_POST['id'];
                    if($delete){
                        if($id>0){
                            foreach($id as $one_by_one){
                            $query_delete_message=mysql_query('delete from product_mali where id ='.$one_by_one.'');
                                if($query_delete_message){
                                    echo "من فضلك انتظر حتى يتم الحذف <img src='images/loading11.gif' />".
                                        "<meta http-equiv='refresh' content='5'>";
                                }
                            }
                        }else{echo "<font color='red'>من فضلك اختر منتج لحذفه!!!";}
                    }
                    /////////////////////////////////////////////

    //Ýí ÍÇáÉ ÖÛØ ÚÑÖ ÍÓÈ ÇáÇÈ
    if($show){
        $sel = "select * from product_mali where langu='en' and id_cat=$sdiv";
        $query = mysql_query($sel);
        $resultrow = mysql_num_rows($query);
            //في حالة وجد بيانات
            if($resultrow > 0){
                /*pagenation step 1 $each_page*/
                $qury="select * from pagenation where id=1";
                $resul=mysql_query($qury);
                while($res = mysql_fetch_array($resul)){
                    extract($res);
                }
                $each_page=$son_mali;
                /*pagenation step 2 $post_count*/
                $qury="select * from product_mali where langu='en'";
                $resul=mysql_query($qury);
                $post_count=mysql_num_rows($resul);
                /*pagenation step 3 $page_count*/
                $page_count=ceil($post_count/$each_page);
                /*pagenation step 4 $page*/
                if(!isset($_GET['page']) || intval($_GET['page']) <=0){
                    $page=1;
                }elseif($_GET['page'] > $page_count){
                    $page=$page_count;
                }else{
                    $page=$_GET['page'];
                }
                /*pagenation step 5 $start*/
                if($post_count >0){
                    $start=$each_page*($page-1);
                }
            $self = $_SERVER['PHP_SELF'];
            echo "<form action='$self' method='post'>";
                echo "<table>";
                    echo "<th class='th_table'>العنوان</th>";
                    echo "<th class='th_table'>تعديل</th>";
                    echo "<th class='th_table'>الحالة</th>";
                    echo "<th class='th_table'>حذف</th>";
                    /*pagenation step 6 fetch data from db*/
                    $sel = "select * from product_mali where langu='en' and id_cat=$sdiv ORDER BY date_time DESC limit $each_page OFFSET $start";
                    $query = mysql_query($sel);
                    while($result = mysql_fetch_array($query)){
                        extract($result);
                        $idd = $id;
                             //change pic when active or not active
                             if($active != 0){
                                $picchange = "<img src='images/apply1.png' width='23' height='23' title='un active' />";
                             }else{
                                $picchange = "<img src='images/apply.png' width='23' height='23' title='active' />";
                             }
                             if($idd%2 != 0){
                                $color="bg1";
                             }else{$color="bg2";}
                        echo "<tr class='$color'>";
                            echo "<td align='center'>$name</td>";
                            echo "<td align='center'>
                                    <a href='edit_son_in_mali.php?id=$idd'><img src='images/edi.png' width='23' height='23' title='Edit' /></a>
                                  </td>";
                            echo "<td align='center'><a href='actveationproduct_mali.php?id=$idd'>$picchange</a></td>";
                            echo "<td align='center'><input type='checkbox' value='$idd' name='id[]' /><img src='images/1122.png' width='23' height='23' title='Mark select to delete' /></td>";
                        echo "</tr>";
                    }
                    echo "<tr>";
                        echo "<td></td>";
                        echo "<td></td>";
                        echo "<td></td>";
                        echo "<td><input class='submit' type='submit' name='حذف' value='Delete' /></td>";
                    echo "</tr>";
                echo "</table>";
            echo "</form>";

                /*pagenation step 7 design button counter*/
                echo "<div class='counter'>";
                echo "<div align='right'><font color='aqu'>إجمالي عدد السجلات : $post_count</font></div>";
                if($page_count > 1){
                                $first = 1;
                                $prev = $page - 1;
                                $next = $page + 1;
                                $last = $page_count;

                                //show first & prev
                                if($page > 1){
                                    echo ' <a href="edit_son_mali.php?page='.$first.'">الأول</a> ';
                                    echo ' <a href="edit_son_mali.php?page='.$prev.'">السابق</a> ';
                                }

                                // show numbers pages
                                for($i=1; $i<=$page_count; $i++){
                                    if($page != $i){
                                        echo ' <a href="edit_son_mali.php?page='.$i.'">'.$i.'</a> ';
                                    }else{
                                        echo '<b>'.$i.'</b>';
                                    }

                                }

                                //show next & last
                                if($page < $page_count){
                                    echo ' <a href="edit_son_mali.php?page='.$next.'">التالي</a> ';
                                    echo ' <a href="edit_son_mali.php?page='.$last.'">الأخير</a> ';
                                }

                }


                    echo "</div>";
                    ///////////////////////////
                    //counter view pagenation
                    echo "<span class='view'>
                        <form action='$self' method='post'>
                            <input type='submit' name='submitview' value='عرض' />
                            <input type='text' value='$each_page' size='1' name='view' /> سجل في الصفحة
                        </form>
                    </span>";
                    $submitview = $_POST['submitview'];
                    $view = $_POST['view'];
                    if($submitview){
                        //when text 0 or text
                        if(!isset($view) || intval($view) <=0){
                            $view=5;
                        }

                        $update="update pagenation set son_mali='$view' where id=1";
                        $qu=mysql_query($update);
                        echo "<meta http-equiv='refresh' content='1'>";
                    }
                    ///////////////////////////


            }else{//في حالة لم يجد بيانات بهذا القسم
                echo "<font color='green'>لا توجد سجلات بهذا القسم</font>";
            }

    }else{
        //Ýí ÍÇáÉ ÇáÊÍãíá ÊáÞÇÆí ááÕÝÍÉ íÚÑÖ ÇáãäÊÌÇÊ ßáåÇ
        $sel = "select * from product_mali where langu='en'";
        $query = mysql_query($sel);
        $resultrow = mysql_num_rows($query);
        //في حالة وجد بيانات
        if($resultrow > 0){

            /*pagenation step 1 $each_page*/
                $qury="select * from pagenation where id=1";
                $resul=mysql_query($qury);
                while($res = mysql_fetch_array($resul)){
                    extract($res);
                }
                $each_page=$son_mali;
                /*pagenation step 2 $post_count*/
                $qury="select * from product_mali where langu='en'";
                $resul=mysql_query($qury);
                $post_count=mysql_num_rows($resul);
                /*pagenation step 3 $page_count*/
                $page_count=ceil($post_count/$each_page);
                /*pagenation step 4 $page*/
                if(!isset($_GET['page']) || intval($_GET['page']) <=0){
                    $page=1;
                }elseif($_GET['page'] > $page_count){
                    $page=$page_count;
                }else{
                    $page=$_GET['page'];
                }
                /*pagenation step 5 $start*/
                if($post_count >0){
                    $start=$each_page*($page-1);
                }

        $self = $_SERVER['PHP_SELF'];
        echo "<form action='$self' method='post'>";
            echo "<table>";
                echo "<th class='th_table'>العنوان</th>";
                    echo "<th class='th_table'>تعديل</th>";
                    echo "<th class='th_table'>الحالة</th>";
                    echo "<th class='th_table'>حذف</th>";
                    /*pagenation step 6 fetch data from db*/
                    $sel = "select * from product_mali where langu='en' ORDER BY date_time DESC limit $each_page OFFSET $start";
                    $query = mysql_query($sel);
                    while($result = mysql_fetch_array($query)){
                    extract($result);
                    $idd = $id;
                             //change pic when active or not active
                             if($active != 0){
                                $picchange = "<img src='images/apply1.png' width='23' height='23' title='un active' />";
                             }else{
                                $picchange = "<img src='images/apply.png' width='23' height='23' title='active' />";
                             }
                             if($idd%2 != 0){
                                $color="bg1";
                             }else{$color="bg2";}
                        echo "<tr class='$color'>";
                            echo "<td align='center'>$name</td>";
                            echo "<td align='center'>
                                    <a href='edit_son_in_mali.php?id=$idd&id_cat22=$id_cat'><img src='images/edi.png' width='23' height='23' title='Edit' /></a>
                                  </td>";
                            echo "<td align='center'><a href='actveationproduct_mali.php?id=$idd'>$picchange</a></td>";
                            echo "<td align='center'><input type='checkbox' value='$idd' name='id[]' /><img src='images/1122.png' width='23' height='23' title='Mark select to delete' /></td>";
                        echo "</tr>";
                }
                echo "<tr>";
                    echo "<td></td>";
                    echo "<td></td>";
                    echo "<td></td>";
                    echo "<td><input class='submit' type='submit' name='delete' value='حذف' /></td>";
                echo "</tr>";
            echo "</table>";
        echo "</form>";

        /*pagenation step 7 design button counter*/
                echo "<div class='counter'>";
                echo "<div align='right'><font color='aqu'>إجمالي عدد السجلات : $post_count</font></div>";
                if($page_count > 1){
                                $first = 1;
                                $prev = $page - 1;
                                $next = $page + 1;
                                $last = $page_count;

                                //show first & prev
                                if($page > 1){
                                    echo ' <a href="edit_son_mali.php?page='.$first.'">الأول</a> ';
                                    echo ' <a href="edit_son_mali.php?page='.$prev.'">السابق</a> ';
                                }

                                // show numbers pages
                                for($i=1; $i<=$page_count; $i++){
                                    if($page != $i){
                                        echo ' <a href="edit_son_mali.php?page='.$i.'">'.$i.'</a> ';
                                    }else{
                                        echo '<b>'.$i.'</b>';
                                    }

                                }

                                //show next & last
                                if($page < $page_count){
                                    echo ' <a href="edit_son_mali.php?page='.$next.'">التالي</a> ';
                                    echo ' <a href="edit_son_mali.php?page='.$last.'">الأخير</a> ';
                                }

                }


                    echo "</div>";
                    ///////////////////////////
                    //counter view pagenation
                    echo "<span class='view'>
                        <form action='$self' method='post'>
                            <input type='submit' name='submitview' value='عرض' />
                            <input type='text' value='$each_page' size='1' name='view' /> سجل في الصفحة
                        </form>
                    </span>";
                    $submitview = $_POST['submitview'];
                    $view = $_POST['view'];
                    if($submitview){
                        //when text 0 or text
                        if(!isset($view) || intval($view) <=0){
                            $view=5;
                        }

                        $update="update pagenation set son_mali='$view' where id=1";
                        $qu=mysql_query($update);
                        echo "<meta http-equiv='refresh' content='1'>";
                    }
                    ///////////////////////////


        }else{
            //في حالة لم يجد بيانات
             echo "<font color='green'>لا يوجد سجلات</font>";
        }
    }
}


///////////////////////////// Edit son /////////////////////////////////////////////////////////////////
function edit_son_maktaba(){
    $show=$_POST['show'];
    $sdiv=$_POST['sdiv'];

                    ///////////////////////////////////////////////
                    //delete news
                    $delete=$_POST['delete'];
                    $id=$_POST['id'];
                    if($delete){
                        if($id>0){
                            foreach($id as $one_by_one){
                            $query_delete_message=mysql_query('delete from product_maktaba where id ='.$one_by_one.'');
                                if($query_delete_message){
                                    echo "من فضلك انتظر حتى يتم الحذف <img src='images/loading11.gif' />".
                                        "<meta http-equiv='refresh' content='5'>";
                                }
                            }
                        }else{echo "<font color='red'>من فضلك اختر منتج لحذفه!!!";}
                    }
                    /////////////////////////////////////////////

    //Ýí ÍÇáÉ ÖÛØ ÚÑÖ ÍÓÈ ÇáÇÈ
    if($show){
        $sel = "select * from product_maktaba where langu='en' and id_cat=$sdiv";
        $query = mysql_query($sel);
        $resultrow = mysql_num_rows($query);
            //في حالة وجد بيانات
            if($resultrow > 0){
                /*pagenation step 1 $each_page*/
                $qury="select * from pagenation where id=1";
                $resul=mysql_query($qury);
                while($res = mysql_fetch_array($resul)){
                    extract($res);
                }
                $each_page=$son_maktaba;
                /*pagenation step 2 $post_count*/
                $qury="select * from product_maktaba where langu='en'";
                $resul=mysql_query($qury);
                $post_count=mysql_num_rows($resul);
                /*pagenation step 3 $page_count*/
                $page_count=ceil($post_count/$each_page);
                /*pagenation step 4 $page*/
                if(!isset($_GET['page']) || intval($_GET['page']) <=0){
                    $page=1;
                }elseif($_GET['page'] > $page_count){
                    $page=$page_count;
                }else{
                    $page=$_GET['page'];
                }
                /*pagenation step 5 $start*/
                if($post_count >0){
                    $start=$each_page*($page-1);
                }
            $self = $_SERVER['PHP_SELF'];
            echo "<form action='$self' method='post'>";
                echo "<table>";
                    echo "<th class='th_table'>العنوان</th>";
                    echo "<th class='th_table'>تعديل</th>";
                    echo "<th class='th_table'>الحالة</th>";
                    echo "<th class='th_table'>حذف</th>";
                    /*pagenation step 6 fetch data from db*/
                    $sel = "select * from product_maktaba where langu='en' and id_cat=$sdiv ORDER BY date_time DESC limit $each_page OFFSET $start";
                    $query = mysql_query($sel);
                    while($result = mysql_fetch_array($query)){
                        extract($result);
                        $idd = $id;
                             //change pic when active or not active
                             if($active != 0){
                                $picchange = "<img src='images/apply1.png' width='23' height='23' title='un active' />";
                             }else{
                                $picchange = "<img src='images/apply.png' width='23' height='23' title='active' />";
                             }
                             if($idd%2 != 0){
                                $color="bg1";
                             }else{$color="bg2";}
                        echo "<tr class='$color'>";
                            echo "<td align='center'>$name</td>";
                            echo "<td align='center'>
                                    <a href='edit_son_in_maktaba.php?id=$idd'><img src='images/edi.png' width='23' height='23' title='Edit' /></a>
                                  </td>";
                            echo "<td align='center'><a href='actveationproduct_maktaba.php?id=$idd'>$picchange</a></td>";
                            echo "<td align='center'><input type='checkbox' value='$idd' name='id[]' /><img src='images/1122.png' width='23' height='23' title='Mark select to delete' /></td>";
                        echo "</tr>";
                    }
                    echo "<tr>";
                        echo "<td></td>";
                        echo "<td></td>";
                        echo "<td></td>";
                        echo "<td><input class='submit' type='submit' name='حذف' value='Delete' /></td>";
                    echo "</tr>";
                echo "</table>";
            echo "</form>";

                /*pagenation step 7 design button counter*/
                echo "<div class='counter'>";
                echo "<div align='right'><font color='aqu'>إجمالي عدد السجلات : $post_count</font></div>";
                if($page_count > 1){
                                $first = 1;
                                $prev = $page - 1;
                                $next = $page + 1;
                                $last = $page_count;

                                //show first & prev
                                if($page > 1){
                                    echo ' <a href="edit_son_maktaba.php?page='.$first.'">الأول</a> ';
                                    echo ' <a href="edit_son_maktaba.php?page='.$prev.'">السابق</a> ';
                                }

                                // show numbers pages
                                for($i=1; $i<=$page_count; $i++){
                                    if($page != $i){
                                        echo ' <a href="edit_son_maktaba.php?page='.$i.'">'.$i.'</a> ';
                                    }else{
                                        echo '<b>'.$i.'</b>';
                                    }

                                }

                                //show next & last
                                if($page < $page_count){
                                    echo ' <a href="edit_son_maktaba.php?page='.$next.'">التالي</a> ';
                                    echo ' <a href="edit_son_maktaba.php?page='.$last.'">الأخير</a> ';
                                }

                }


                    echo "</div>";
                    ///////////////////////////
                    //counter view pagenation
                    echo "<span class='view'>
                        <form action='$self' method='post'>
                            <input type='submit' name='submitview' value='عرض' />
                            <input type='text' value='$each_page' size='1' name='view' /> سجل في الصفحة
                        </form>
                    </span>";
                    $submitview = $_POST['submitview'];
                    $view = $_POST['view'];
                    if($submitview){
                        //when text 0 or text
                        if(!isset($view) || intval($view) <=0){
                            $view=5;
                        }

                        $update="update pagenation set son_maktaba='$view' where id=1";
                        $qu=mysql_query($update);
                        echo "<meta http-equiv='refresh' content='1'>";
                    }
                    ///////////////////////////


            }else{//في حالة لم يجد بيانات بهذا القسم
                echo "<font color='green'>لا توجد سجلات بهذا القسم</font>";
            }

    }else{
        //Ýí ÍÇáÉ ÇáÊÍãíá ÊáÞÇÆí ááÕÝÍÉ íÚÑÖ ÇáãäÊÌÇÊ ßáåÇ
        $sel = "select * from product_maktaba where langu='en'";
        $query = mysql_query($sel);
        $resultrow = mysql_num_rows($query);
        //في حالة وجد بيانات
        if($resultrow > 0){

            /*pagenation step 1 $each_page*/
                $qury="select * from pagenation where id=1";
                $resul=mysql_query($qury);
                while($res = mysql_fetch_array($resul)){
                    extract($res);
                }
                $each_page=$son_maktaba;
                /*pagenation step 2 $post_count*/
                $qury="select * from product_maktaba where langu='en'";
                $resul=mysql_query($qury);
                $post_count=mysql_num_rows($resul);
                /*pagenation step 3 $page_count*/
                $page_count=ceil($post_count/$each_page);
                /*pagenation step 4 $page*/
                if(!isset($_GET['page']) || intval($_GET['page']) <=0){
                    $page=1;
                }elseif($_GET['page'] > $page_count){
                    $page=$page_count;
                }else{
                    $page=$_GET['page'];
                }
                /*pagenation step 5 $start*/
                if($post_count >0){
                    $start=$each_page*($page-1);
                }

        $self = $_SERVER['PHP_SELF'];
        echo "<form action='$self' method='post'>";
            echo "<table>";
                echo "<th class='th_table'>العنوان</th>";
                    echo "<th class='th_table'>تعديل</th>";
                    echo "<th class='th_table'>الحالة</th>";
                    echo "<th class='th_table'>حذف</th>";
                    /*pagenation step 6 fetch data from db*/
                    $sel = "select * from product_maktaba where langu='en' ORDER BY date_time DESC limit $each_page OFFSET $start";
                    $query = mysql_query($sel);
                    while($result = mysql_fetch_array($query)){
                    extract($result);
                    $idd = $id;
                             //change pic when active or not active
                             if($active != 0){
                                $picchange = "<img src='images/apply1.png' width='23' height='23' title='un active' />";
                             }else{
                                $picchange = "<img src='images/apply.png' width='23' height='23' title='active' />";
                             }
                             if($idd%2 != 0){
                                $color="bg1";
                             }else{$color="bg2";}
                        echo "<tr class='$color'>";
                            echo "<td align='center'>$name</td>";
                            echo "<td align='center'>
                                    <a href='edit_son_in_maktaba.php?id=$idd&id_cat22=$id_cat'><img src='images/edi.png' width='23' height='23' title='Edit' /></a>
                                  </td>";
                            echo "<td align='center'><a href='actveationproduct_maktaba.php?id=$idd'>$picchange</a></td>";
                            echo "<td align='center'><input type='checkbox' value='$idd' name='id[]' /><img src='images/1122.png' width='23' height='23' title='Mark select to delete' /></td>";
                        echo "</tr>";
                }
                echo "<tr>";
                    echo "<td></td>";
                    echo "<td></td>";
                    echo "<td></td>";
                    echo "<td><input class='submit' type='submit' name='delete' value='حذف' /></td>";
                echo "</tr>";
            echo "</table>";
        echo "</form>";

        /*pagenation step 7 design button counter*/
                echo "<div class='counter'>";
                echo "<div align='right'><font color='aqu'>إجمالي عدد السجلات : $post_count</font></div>";
                if($page_count > 1){
                                $first = 1;
                                $prev = $page - 1;
                                $next = $page + 1;
                                $last = $page_count;

                                //show first & prev
                                if($page > 1){
                                    echo ' <a href="edit_son_maktaba.php?page='.$first.'">الأول</a> ';
                                    echo ' <a href="edit_son_maktaba.php?page='.$prev.'">السابق</a> ';
                                }

                                // show numbers pages
                                for($i=1; $i<=$page_count; $i++){
                                    if($page != $i){
                                        echo ' <a href="edit_son_maktaba.php?page='.$i.'">'.$i.'</a> ';
                                    }else{
                                        echo '<b>'.$i.'</b>';
                                    }

                                }

                                //show next & last
                                if($page < $page_count){
                                    echo ' <a href="edit_son_maktaba.php?page='.$next.'">التالي</a> ';
                                    echo ' <a href="edit_son_maktaba.php?page='.$last.'">الأخير</a> ';
                                }

                }


                    echo "</div>";
                    ///////////////////////////
                    //counter view pagenation
                    echo "<span class='view'>
                        <form action='$self' method='post'>
                            <input type='submit' name='submitview' value='عرض' />
                            <input type='text' value='$each_page' size='1' name='view' /> سجل في الصفحة
                        </form>
                    </span>";
                    $submitview = $_POST['submitview'];
                    $view = $_POST['view'];
                    if($submitview){
                        //when text 0 or text
                        if(!isset($view) || intval($view) <=0){
                            $view=5;
                        }

                        $update="update pagenation set son_maktaba='$view' where id=1";
                        $qu=mysql_query($update);
                        echo "<meta http-equiv='refresh' content='1'>";
                    }
                    ///////////////////////////


        }else{
            //في حالة لم يجد بيانات
             echo "<font color='green'>لا يوجد سجلات</font>";
        }
    }
}



///////////////////////////// edit father ////////////////////////////////////////////////////////////

function edit_father(){
    $show=$_POST['show'];

        //Ýí ÍÇáÉ ÇáÊÍãíá ÊáÞÇÆí ááÕÝÍÉ íÚÑÖ ÇáãäÊÌÇÊ ßáåÇ
        $sel = "select * from cat where langu='en'";
        $query = mysql_query($sel);
        $resultrow = mysql_num_rows($query);
        //في حالة وجد بيانات
        if($resultrow > 0){
            /*pagenation step 1 $each_page*/
            $qury="select * from pagenation where id=1";
            $resul=mysql_query($qury);
            while($res = mysql_fetch_array($resul)){
                extract($res);
            }
            $each_page=$father;
            /*pagenation step 2 $post_count*/
            $qury="select * from cat where langu='en'";
            $resul=mysql_query($qury);
            $post_count=mysql_num_rows($resul);
            /*pagenation step 3 $page_count*/
            $page_count=ceil($post_count/$each_page);
            /*pagenation step 4 $page*/
            if(!isset($_GET['page']) || intval($_GET['page']) <=0){
                $page=1;
            }elseif($_GET['page'] > $page_count){
                $page=$page_count;
            }else{
                $page=$_GET['page'];
            }
            /*pagenation step 5 $start*/
            if($post_count >0){
                $start=$each_page*($page-1);
            }

                    ///////////////////////////////////////////////
                    //delete father
                    $delete=$_POST['delete'];
                    $id=$_POST['id'];
                    if($delete){
                        if($id>0){
                            foreach($id as $one_by_one){
                            $query_delete_message=mysql_query('delete from cat where id ='.$one_by_one.'');
                                if($query_delete_message){
                                    echo "من فضلك انتظر حتى يتم الحذف <img src='images/loading21.gif' />".
                                        "<meta http-equiv='refresh' content='5'>";
                                }
                            }
                        }else{echo "<font color='red'>من فضلك اختر قسم لحذفه!!!";}
                    }
                    /////////////////////////////////////////////

        $self = $_SERVER['PHP_SELF'];
        echo "<form action='$self' method='post'>";
            echo "<table>";

                echo "<th class='th_table'>اسم القسم</th>";
                echo "<th class='th_table'>تعديل</th>";
                echo "<th class='th_table'>الحالة</th>";
                echo "<th class='th_table'>delete</th>";
            /*pagenation step 6 fetch data from db*/
                $sel = "select * from cat where langu='en' ORDER BY date_time DESC limit $each_page OFFSET $start";
                $query = mysql_query($sel);
                while($result = mysql_fetch_array($query)){
                    extract($result);

                    $idd = $id;
                            //change pic when active or not active
                             if($active != 0){
                                $picchange = "<img src='images/apply1.png' width='23' height='23' title='un active' />";
                             }else{
                                $picchange = "<img src='images/apply.png' width='23' height='23' title='active' />";
                             }
                             if($idd%2 != 0){
                                $color="bg1";
                             }else{$color="bg2";}
                    echo "<tr class='$color'>";
                        echo "<td class='td_table'>$name</td>";
                        echo "<td align='center'>
                                <a href='edit_father_in.php?id=$idd'><img src='images/edi.png' width='23' height='23' title='Edit' /></a>
                              </td>";

                        echo "<td align='center'><a href='activeationfather.php?id=$idd'>$picchange</a></td>";
                        echo "<td align='center'><input type='checkbox' value='$idd' name='id[]' /><img src='images/1122.png' width='23' height='23' title='Mark select to delete' /></td>";
                    echo "</tr>";
                }
                echo "<tr>";
                    echo "<td></td>";
                    echo "<td></td>";
                    echo "<td></td>";
                    echo "<td><input class='submit' type='submit' name='delete' value='Delete' /></td>";
                echo "</tr>";
            echo "</table>";
        echo "</form>";

              /*pagenation step 7 design button counter*/
            echo "<div class='counter'>";
                echo "<div align='right'><font color='aqu'>إجمالي عدد الأقسام : $post_count</font></div>";
                if($page_count > 1){
                                $first = 1;
                                $prev = $page - 1;
                                $next = $page + 1;
                                $last = $page_count;

                                //show first & prev
                                if($page > 1){
                                    echo ' <a href="edit_father.php?page='.$first.'">الأول</a> ';
                                    echo ' <a href="edit_father.php?page='.$prev.'">السابق</a> ';
                                }

                                // show numbers pages
                                for($i=1; $i<=$page_count; $i++){
                                    if($page != $i){
                                        echo ' <a href="edit_father.php?page='.$i.'">'.$i.'</a> ';
                                    }else{
                                        echo '<b>'.$i.'</b>';
                                    }

                                }

                                //show next & last
                                if($page < $page_count){
                                    echo ' <a href="edit_father.php?page='.$next.'">التالي</a> ';
                                    echo ' <a href="edit_father.php?page='.$last.'">الأخير</a> ';
                                }

                }


            echo "</div>";
                    ///////////////////////////
                    //counter view pagenation
                    echo "<span class='view'>
                        <form action='$self' method='post'>
                            <input type='submit' name='submitview' value='عرض' />
                            <input type='text' value='$each_page' size='1' name='view' /> سجل في الصفحة
                        </form>
                    </span>";
                    $submitview = $_POST['submitview'];
                    $view = $_POST['view'];
                    if($submitview){
                        //when text 0 or text
                        if(!isset($view) || intval($view) <=0){
                            $view=5;
                        }

                        $update="update pagenation set father='$view' where id=1";
                        $qu=mysql_query($update);
                        echo "<meta http-equiv='refresh' content='1'>";
                    }
                    ///////////////////////////

        }else{
            //في حالة لم يجد منتجات
            echo "<font color='green'>لا يوجد منتجات بأي قسم</font>";
        }

}

///////////////////////////// Edit son /////////////////////////////////////////////////////////////////
function edit_son(){
    $show=$_POST['show'];
    $sdiv=$_POST['sdiv'];

                    ///////////////////////////////////////////////
                    //delete news
                    $delete=$_POST['delete'];
                    $id=$_POST['id'];
                    if($delete){
                        if($id>0){
                            foreach($id as $one_by_one){
                            $query_delete_message=mysql_query('delete from product where id ='.$one_by_one.'');
                                if($query_delete_message){
                                    echo "من فضلك انتظر حتى يتم الحذف <img src='images/loading11.gif' />".
                                        "<meta http-equiv='refresh' content='5'>";
                                }
                            }
                        }else{echo "<font color='red'>من فضلك اختر منتج لحذفه!!!";}
                    }
                    /////////////////////////////////////////////

    //Ýí ÍÇáÉ ÖÛØ ÚÑÖ ÍÓÈ ÇáÇÈ
    if($show){
        $sel = "select * from product where langu='en' and id_cat=$sdiv";
        $query = mysql_query($sel);
        $resultrow = mysql_num_rows($query);
            //في حالة وجد بيانات
            if($resultrow > 0){
                /*pagenation step 1 $each_page*/
                $qury="select * from pagenation where id=1";
                $resul=mysql_query($qury);
                while($res = mysql_fetch_array($resul)){
                    extract($res);
                }
                $each_page=$son;
                /*pagenation step 2 $post_count*/
                $qury="select * from product where langu='en'";
                $resul=mysql_query($qury);
                $post_count=mysql_num_rows($resul);
                /*pagenation step 3 $page_count*/
                $page_count=ceil($post_count/$each_page);
                /*pagenation step 4 $page*/
                if(!isset($_GET['page']) || intval($_GET['page']) <=0){
                    $page=1;
                }elseif($_GET['page'] > $page_count){
                    $page=$page_count;
                }else{
                    $page=$_GET['page'];
                }
                /*pagenation step 5 $start*/
                if($post_count >0){
                    $start=$each_page*($page-1);
                }
            $self = $_SERVER['PHP_SELF'];
            echo "<form action='$self' method='post'>";
                echo "<table>";
                    echo "<th class='th_table'>اسم المنتج</th>";
                    echo "<th class='th_table'>تعديل</th>";
                    echo "<th class='th_table'>الحالة</th>";
                    echo "<th class='th_table'>حذف</th>";
                    /*pagenation step 6 fetch data from db*/
                    $sel = "select * from product where langu='en' and id_cat=$sdiv ORDER BY date_time DESC limit $each_page OFFSET $start";
                    $query = mysql_query($sel);
                    while($result = mysql_fetch_array($query)){
                        extract($result);
                        $idd = $id;
                             //change pic when active or not active
                             if($active != 0){
                                $picchange = "<img src='images/apply1.png' width='23' height='23' title='un active' />";
                             }else{
                                $picchange = "<img src='images/apply.png' width='23' height='23' title='active' />";
                             }
                             if($idd%2 != 0){
                                $color="bg1";
                             }else{$color="bg2";}
                        echo "<tr class='$color'>";
                            echo "<td align='center'>$name</td>";
                            echo "<td align='center'>
                                    <a href='edit_son_in.php?id=$idd'><img src='images/edi.png' width='23' height='23' title='Edit' /></a>
                                  </td>";
                            echo "<td align='center'><a href='actveationproduct.php?id=$idd'>$picchange</a></td>";
                            echo "<td align='center'><input type='checkbox' value='$idd' name='id[]' /><img src='images/1122.png' width='23' height='23' title='Mark select to delete' /></td>";
                        echo "</tr>";
                    }
                    echo "<tr>";
                        echo "<td></td>";
                        echo "<td></td>";
                        echo "<td></td>";
                        echo "<td><input class='submit' type='submit' name='حذف' value='Delete' /></td>";
                    echo "</tr>";
                echo "</table>";
            echo "</form>";

                /*pagenation step 7 design button counter*/
                echo "<div class='counter'>";
                echo "<div align='right'><font color='aqu'>إجمالي عدد السجلات : $post_count</font></div>";
                if($page_count > 1){
                                $first = 1;
                                $prev = $page - 1;
                                $next = $page + 1;
                                $last = $page_count;

                                //show first & prev
                                if($page > 1){
                                    echo ' <a href="edit_son.php?page='.$first.'">الأول</a> ';
                                    echo ' <a href="edit_son.php?page='.$prev.'">السابق</a> ';
                                }

                                // show numbers pages
                                for($i=1; $i<=$page_count; $i++){
                                    if($page != $i){
                                        echo ' <a href="edit_son.php?page='.$i.'">'.$i.'</a> ';
                                    }else{
                                        echo '<b>'.$i.'</b>';
                                    }

                                }

                                //show next & last
                                if($page < $page_count){
                                    echo ' <a href="edit_son.php?page='.$next.'">التالي</a> ';
                                    echo ' <a href="edit_son.php?page='.$last.'">الأخير</a> ';
                                }

                }


                    echo "</div>";
                    ///////////////////////////
                    //counter view pagenation
                    echo "<span class='view'>
                        <form action='$self' method='post'>
                            <input type='submit' name='submitview' value='عرض' />
                            <input type='text' value='$each_page' size='1' name='view' /> سجل في الصفحة
                        </form>
                    </span>";
                    $submitview = $_POST['submitview'];
                    $view = $_POST['view'];
                    if($submitview){
                        //when text 0 or text
                        if(!isset($view) || intval($view) <=0){
                            $view=5;
                        }

                        $update="update pagenation set son='$view' where id=1";
                        $qu=mysql_query($update);
                        echo "<meta http-equiv='refresh' content='1'>";
                    }
                    ///////////////////////////


            }else{//في حالة لم يجد بيانات بهذا القسم
                echo "<font color='green'>لا توجد منتجات بهذا القسم</font>";
            }

    }else{
        //Ýí ÍÇáÉ ÇáÊÍãíá ÊáÞÇÆí ááÕÝÍÉ íÚÑÖ ÇáãäÊÌÇÊ ßáåÇ
        $sel = "select * from product where langu='en'";
        $query = mysql_query($sel);
        $resultrow = mysql_num_rows($query);
        //في حالة وجد بيانات
        if($resultrow > 0){

            /*pagenation step 1 $each_page*/
                $qury="select * from pagenation where id=1";
                $resul=mysql_query($qury);
                while($res = mysql_fetch_array($resul)){
                    extract($res);
                }
                $each_page=$son;
                /*pagenation step 2 $post_count*/
                $qury="select * from product where langu='en'";
                $resul=mysql_query($qury);
                $post_count=mysql_num_rows($resul);
                /*pagenation step 3 $page_count*/
                $page_count=ceil($post_count/$each_page);
                /*pagenation step 4 $page*/
                if(!isset($_GET['page']) || intval($_GET['page']) <=0){
                    $page=1;
                }elseif($_GET['page'] > $page_count){
                    $page=$page_count;
                }else{
                    $page=$_GET['page'];
                }
                /*pagenation step 5 $start*/
                if($post_count >0){
                    $start=$each_page*($page-1);
                }

        $self = $_SERVER['PHP_SELF'];
        echo "<form action='$self' method='post'>";
            echo "<table>";
                echo "<th class='th_table'>اسم المنتج</th>";
                    echo "<th class='th_table'>تعديل</th>";
                    echo "<th class='th_table'>الحالة</th>";
                    echo "<th class='th_table'>حذف</th>";
                    /*pagenation step 6 fetch data from db*/
                    $sel = "select * from product where langu='en' ORDER BY date_time DESC limit $each_page OFFSET $start";
                    $query = mysql_query($sel);
                    while($result = mysql_fetch_array($query)){
                    extract($result);
                    $idd = $id;
                             //change pic when active or not active
                             if($active != 0){
                                $picchange = "<img src='images/apply1.png' width='23' height='23' title='un active' />";
                             }else{
                                $picchange = "<img src='images/apply.png' width='23' height='23' title='active' />";
                             }
                             if($idd%2 != 0){
                                $color="bg1";
                             }else{$color="bg2";}
                        echo "<tr class='$color'>";
                            echo "<td align='center'>$name</td>";
                            echo "<td align='center'>
                                    <a href='edit_son_in.php?id=$idd&id_cat22=$id_cat'><img src='images/edi.png' width='23' height='23' title='Edit' /></a>
                                  </td>";
                            echo "<td align='center'><a href='actveationproduct.php?id=$idd'>$picchange</a></td>";
                            echo "<td align='center'><input type='checkbox' value='$idd' name='id[]' /><img src='images/1122.png' width='23' height='23' title='Mark select to delete' /></td>";
                        echo "</tr>";
                }
                echo "<tr>";
                    echo "<td></td>";
                    echo "<td></td>";
                    echo "<td></td>";
                    echo "<td><input class='submit' type='submit' name='delete' value='حذف' /></td>";
                echo "</tr>";
            echo "</table>";
        echo "</form>";

        /*pagenation step 7 design button counter*/
                echo "<div class='counter'>";
                echo "<div align='right'><font color='aqu'>إجمالي عدد السجلات : $post_count</font></div>";
                if($page_count > 1){
                                $first = 1;
                                $prev = $page - 1;
                                $next = $page + 1;
                                $last = $page_count;

                                //show first & prev
                                if($page > 1){
                                    echo ' <a href="edit_son.php?page='.$first.'">الأول</a> ';
                                    echo ' <a href="edit_son.php?page='.$prev.'">السابق</a> ';
                                }

                                // show numbers pages
                                for($i=1; $i<=$page_count; $i++){
                                    if($page != $i){
                                        echo ' <a href="edit_son.php?page='.$i.'">'.$i.'</a> ';
                                    }else{
                                        echo '<b>'.$i.'</b>';
                                    }

                                }

                                //show next & last
                                if($page < $page_count){
                                    echo ' <a href="edit_son.php?page='.$next.'">التالي</a> ';
                                    echo ' <a href="edit_son.php?page='.$last.'">الأخير</a> ';
                                }

                }


                    echo "</div>";
                    ///////////////////////////
                    //counter view pagenation
                    echo "<span class='view'>
                        <form action='$self' method='post'>
                            <input type='submit' name='submitview' value='عرض' />
                            <input type='text' value='$each_page' size='1' name='view' /> سجل في الصفحة
                        </form>
                    </span>";
                    $submitview = $_POST['submitview'];
                    $view = $_POST['view'];
                    if($submitview){
                        //when text 0 or text
                        if(!isset($view) || intval($view) <=0){
                            $view=5;
                        }

                        $update="update pagenation set son='$view' where id=1";
                        $qu=mysql_query($update);
                        echo "<meta http-equiv='refresh' content='1'>";
                    }
                    ///////////////////////////


        }else{
            //في حالة لم يجد بيانات
            echo "<font color='green'>لا توجد سجلات بهذا القسم</font>";
        }
    }
}


//------------------------------------------ edit news page ------------------------------------------
function edit_news(){
            $sel = "select * from news where langu='en'";
            $query = mysql_query($sel);
            $resultrow = mysql_num_rows($query);
            //في حالة وجد بيانات
            if($resultrow > 0){
                /*pagenation step 1 $each_page*/
                $qury="select * from pagenation where id=1";
                $resul=mysql_query($qury);
                while($res = mysql_fetch_array($resul)){
                    extract($res);
                }
                $each_page=$news;
                /*2 pagenation step 2 $post_count*/
                $qury="select * from news where langu='en'";
                $resul=mysql_query($qury);
                $post_count=mysql_num_rows($resul);
                /*3 pagenation step 3 $page_count*/
                $page_count=ceil($post_count/$each_page);
                /*4 pagenation step 4 $page*/
                if(!isset($_GET['page']) || intval($_GET['page']) <=0){
                    $page=1;
                }elseif($_GET['page'] > $page_count){
                    $page=$page_count;
                }else{
                    $page=$_GET['page'];
                }
                /*5 pagenation step 5 $start*/
                if($post_count >0){
                    $start=$each_page*($page-1);
                }


                /*6 pagenation step 6 fetch data from db*/
                $sel = "select * from news where langu='en' ORDER BY date_time DESC limit $each_page OFFSET $start";
                $query = mysql_query($sel);
                $selrow=mysql_num_rows($query);
                //Ýí ÍÇáÉ æÌÏ ÇÎÈÇÑ
                if($selrow){
                    $self = $_SERVER['PHP_SELF'];
                    echo "<form action='$self' method='post'>";
                        echo "<table cellpadding='5' cellspacing='5' width='600' align='center'>";
                            echo "<th class='th_table'>صورة الخبر</th>";
                            echo "<th class='th_table'>عنوان الخبر</th>";
                            echo "<th class='th_table'>تاريخ الإضافة</th>";
                            echo "<th class='th_table'>الحالة</th>";
                            echo "<th class='th_table'>تعديل</th>";
                            echo "<th class='th_table'>delete</th>";

                        while($result = mysql_fetch_array($query)){
                            extract($result);
                            $idd = $id;

                             //change pic when active or not active
                             if($active != 0){
                                $picchange = "<img src='images/apply1.png' width='23' height='23' title='un active' />";
                             }else{
                                $picchange = "<img src='images/apply.png' width='23' height='23' title='active' />";
                             }



                            $path = "../upload/news_en";
                            if($idd%2 != 0){
                                $color="bg1";
                            }else{$color="bg2";}
                            echo "<tr class='$color'>";
                                echo "<td align='center'><img src='$path/$picname' style='padding:5px;' width='50' height='50' /></td>";
                                echo "<td align='right'>$title</td>";
                                echo "<td align='center'>$date_time</td>";
                                echo "<td align='center'><a href='activeation.php?id=$idd'>$picchange</a></td>";
                                echo "<td align='center'><a href='edit_news_in.php?id=$idd'><img src='images/edi.png' width='23' height='23' title='Edit' /></a><br />Edit</td>";
                                echo "<td align='center'><input type='checkbox' value='$idd' name='id[]' /><img src='images/1122.png' width='23' height='23' title='Mark select to delete' /></td>";
                            echo "</tr>";



                        }
                            echo "<tr>";
                                echo "<td></td>";
                                echo "<td></td>";
                                echo "<td></td>";
                                echo "<td></td>";
                                echo "<td></td>";
                                echo "<td><input class='submit' type='submit' name='delete' value='Delete' /></td>";
                            echo "</tr>";
                        echo "</table>";
                    echo "<form>";

                    ///////////////////////////////////////////////
                    //delete news
                    $delete=$_POST['delete'];
                    $id=$_POST['id'];
                    if($delete){
                        if($id>0){
                            foreach($id as $one_by_one){
                            $query_delete_message=mysql_query('delete from news where id ='.$one_by_one.'');
                                if($query_delete_message){
                                    echo "من فضلك انتظر حتى يتم الحذف <img src='images/loading11.gif' />".
                                        "<meta http-equiv='refresh' content='5'>";
                                }
                            }
                        }else{echo "<font color='red'>من فضلك اختر منتج لحذفه!!!";}
                    }
                    /////////////////////////////////////////////

                    /*pagenation step 7 design button counter*/
                echo "<div class='counter'>";
                echo "<div align='right'><font color='aqu'>إجمالي عدد الأخبار : $post_count</font></div>";
                if($page_count > 1){
                                $first = 1;
                                $prev = $page - 1;
                                $next = $page + 1;
                                $last = $page_count;

                                //show first & prev
                                if($page > 1){
                                    echo ' <a href="edit_news.php?page='.$first.'">الأول</a> ';
                                    echo ' <a href="edit_news.php?page='.$prev.'">السابق</a> ';
                                }

                                // show numbers pages
                                for($i=1; $i<=$page_count; $i++){
                                    if($page != $i){
                                        echo ' <a href="edit_news.php?page='.$i.'">'.$i.'</a> ';
                                    }else{
                                        echo '<b>'.$i.'</b>';
                                    }

                                }

                                //show next & last
                                if($page < $page_count){
                                    echo ' <a href="edit_news.php?page='.$next.'">التالي</a> ';
                                    echo ' <a href="edit_news.php?page='.$last.'">الأخير</a> ';
                                }

                    }
                echo "</div>";

                    ///////////////////////////
                    //counter view pagenation
                    echo "<span class='view'>
                        <form action='$self' method='post'>
                            <input type='submit' name='submitview' value='عرض' />
                            <input type='text' value='$each_page' size='1' name='view' /> سجل في الصفحة
                        </form>
                    </span>";
                    $submitview = $_POST['submitview'];
                    $view = $_POST['view'];
                    if($submitview){
                        //when text 0 or text
                        if(!isset($view) || intval($view) <=0){
                            $view=5;
                        }

                        $update="update pagenation set news='$view' where id=1";
                        $qu=mysql_query($update);
                        echo "<meta http-equiv='refresh' content='1'>";
                    }
                    ///////////////////////////

                }else{ echo "<font color='green'>لا توجد أخبار</font>";}
           }else{
                //في حالة لم يجد بيانات
                echo "<font color='green'> لا توجد أخبار حاليا</font>";
           }
}

//--------------------------------- select color_row_table -------------------------------------------
function color_row_table(){
     if($idd%2==0){
        $color='#000000';
     }else{
        $color='#ffffff';
     }
}
//--------------------------------- make fckeditor -------------------------------------------
function make_fckeditor(){
                                    include_once ('fckeditor/fckeditor.php');
                                    $oFCKeditor = new FCKeditor ( 'desc' );
                                    $oFCKeditor->BasePath = 'fckeditor/';
                                    $oFCKeditor->Width =600;
                                    $oFCKeditor->Height =400;
                                    $oFCKeditor->Value =$desc;
                                    $oFCKeditor->Create ();
}


//--------------------------------- home page -------------------------------------------

function fetch_fckedit_homeintro(){

                                    //fetch data from db to fckeditor
                                    $seldb = "select * from pagefixed where id = 5";
                                    $querydb = mysql_query($seldb);
                                    while($resultdb = mysql_fetch_array($querydb)){
                                        if($resultdb){
                                            extract($resultdb);
                                            $content=$content;
                                        }
                                    }
                                    //make fckeditor
                                    include_once ('fckeditor/fckeditor.php');
                                    $oFCKeditor = new FCKeditor ( 'desc' );
                                    $oFCKeditor->BasePath = 'fckeditor/';
                                    $oFCKeditor->Width =670;
                                    $oFCKeditor->Height =400;
                                    $oFCKeditor->Value =$content;
                                    $oFCKeditor->Create ();
}

//--------------------------------- about page -------------------------------------------

function fetch_fckedit_about(){
                                    //fetch data from db to fckeditor

                                    $seldb = "select * from pagefixed where id = 7";
                                    $querydb = mysql_query($seldb);
                                    while($resultdb = mysql_fetch_array($querydb)){
                                        if($resultdb){
                                            extract($resultdb);
                                            $content=$content;
                                        }
                                    }?>
                                    <br /><br />
                                    <td valign="top">المقدمة :</td>
                                    <td><textarea rows="5" cols="65" name="intro"><?=$intro?></textarea></td>
                                    <br /><br />
                                    <?
                                    //make fckeditor
                                    include_once ('fckeditor/fckeditor.php');
                                    $oFCKeditor = new FCKeditor ( 'desc' );
                                    $oFCKeditor->BasePath = 'fckeditor/';
                                    $oFCKeditor->Width =670;
                                    $oFCKeditor->Height =400;
                                    $oFCKeditor->Value =$content;
                                    $oFCKeditor->Create ();
}

//--------------------------------- fetch_fckedit_chairman page -------------------------------------------

function fetch_fckedit_chairman(){
                                    //fetch data from db to fckeditor

                                    $seldb = "select * from pagefixed where id = 14";
                                    $querydb = mysql_query($seldb);
                                    while($resultdb = mysql_fetch_array($querydb)){
                                        if($resultdb){
                                            extract($resultdb);
                                            $content=$content;
                                        }
                                    }?>
                                    <br /><br />
                                    <td valign="top">المقدمة :</td>
                                    <td><textarea rows="5" cols="65" name="intro"><?=$intro?></textarea></td>
                                    <br /><br />
                                    <?
                                    //make fckeditor
                                    include_once ('fckeditor/fckeditor.php');
                                    $oFCKeditor = new FCKeditor ( 'desc' );
                                    $oFCKeditor->BasePath = 'fckeditor/';
                                    $oFCKeditor->Width =670;
                                    $oFCKeditor->Height =400;
                                    $oFCKeditor->Value =$content;
                                    $oFCKeditor->Create ();
}
//--------------------------------- fetch_fckedit_link_vip page -------------------------------------------

function fetch_fckedit_link_vip(){
                                    //fetch data from db to fckeditor

                                    $seldb = "select * from pagefixed where id = 12";
                                    $querydb = mysql_query($seldb);
                                    while($resultdb = mysql_fetch_array($querydb)){
                                        if($resultdb){
                                            extract($resultdb);
                                            $content=$content;
                                        }
                                    }
                                    //make fckeditor
                                    include_once ('fckeditor/fckeditor.php');
                                    $oFCKeditor = new FCKeditor ( 'desc' );
                                    $oFCKeditor->BasePath = 'fckeditor/';
                                    $oFCKeditor->Width =670;
                                    $oFCKeditor->Height =400;
                                    $oFCKeditor->Value =$content;
                                    $oFCKeditor->Create ();
}

//--------------------------------- fetch_fckedit_good_inveroment page -------------------------------------------

function fetch_fckedit_good_inveroment(){
                                    //fetch data from db to fckeditor

                                    $seldb = "select * from pagefixed where id = 10";
                                    $querydb = mysql_query($seldb);
                                    while($resultdb = mysql_fetch_array($querydb)){
                                        if($resultdb){
                                            extract($resultdb);
                                            $content=$content;
                                        }
                                    }
                                    //make fckeditor
                                    include_once ('fckeditor/fckeditor.php');
                                    $oFCKeditor = new FCKeditor ( 'desc' );
                                    $oFCKeditor->BasePath = 'fckeditor/';
                                    $oFCKeditor->Width =670;
                                    $oFCKeditor->Height =400;
                                    $oFCKeditor->Value =$content;
                                    $oFCKeditor->Create ();
}

//--------------------------------- fetch_case_study page -------------------------------------------

function fetch_case_study(){
                                    //fetch data from db to fckeditor

                                    $seldb = "select * from pagefixed where id = 9";
                                    $querydb = mysql_query($seldb);
                                    while($resultdb = mysql_fetch_array($querydb)){
                                        if($resultdb){
                                            extract($resultdb);
                                            $content=$content;
                                        }
                                    }
                                    //make fckeditor
                                    include_once ('fckeditor/fckeditor.php');
                                    $oFCKeditor = new FCKeditor ( 'desc' );
                                    $oFCKeditor->BasePath = 'fckeditor/';
                                    $oFCKeditor->Width =670;
                                    $oFCKeditor->Height =400;
                                    $oFCKeditor->Value =$content;
                                    $oFCKeditor->Create ();
}

//--------------------------------- fetch_fckedit_good_inveroment page -------------------------------------------

function fetch_fckedit_serv_clear(){
                                    //fetch data from db to fckeditor

                                    $seldb = "select * from pagefixed where id = 9";
                                    $querydb = mysql_query($seldb);
                                    while($resultdb = mysql_fetch_array($querydb)){
                                        if($resultdb){
                                            extract($resultdb);
                                            $content=$content;
                                        }
                                    }
                                    //make fckeditor
                                    include_once ('fckeditor/fckeditor.php');
                                    $oFCKeditor = new FCKeditor ( 'desc' );
                                    $oFCKeditor->BasePath = 'fckeditor/';
                                    $oFCKeditor->Width =670;
                                    $oFCKeditor->Height =400;
                                    $oFCKeditor->Value =$content;
                                    $oFCKeditor->Create ();
}

//--------------------------------- product page -------------------------------------------
/*
function fetch_fckedit_product(){
                                    //fetch data from db to fckeditor

                                    $seldb = "select * from pagefixed where id = 4";
                                    $querydb = mysql_query($seldb);
                                    while($resultdb = mysql_fetch_array($querydb)){
                                        if($resultdb){
                                            extract($resultdb);
                                            $content=$content;
                                        }
                                    }
                                    //make fckeditor
                                    include_once ('fckeditor/fckeditor.php');
                                    $oFCKeditor = new FCKeditor ( 'desc' );
                                    $oFCKeditor->BasePath = 'fckeditor/';
                                    $oFCKeditor->Width =670;
                                    $oFCKeditor->Height =400;
                                    $oFCKeditor->Value =$content;
                                    $oFCKeditor->Create ();
}
*/
//--------------------------------- contact page -------------------------------------------

function fetch_fckedit_contact(){
                                    //fetch data from db to fckeditor

                                    $seldb = "select * from pagefixed where id = 8";
                                    $querydb = mysql_query($seldb);
                                    while($resultdb = mysql_fetch_array($querydb)){
                                        if($resultdb){
                                            extract($resultdb);
                                            $content=$content;
                                        }
                                    }
                                    //make fckeditor
                                    include_once ('fckeditor/fckeditor.php');
                                    $oFCKeditor = new FCKeditor ( 'desc' );
                                    $oFCKeditor->BasePath = 'fckeditor/';
                                    $oFCKeditor->Width =670;
                                    $oFCKeditor->Height =400;
                                    $oFCKeditor->Value =$content;
                                    $oFCKeditor->Create ();
}

//--------------------------------- contact page -------------------------------------------

function fetch_fckedit_fro3na(){
                                    //fetch data from db to fckeditor

                                    $seldb = "select * from pagefixed where id = 11";
                                    $querydb = mysql_query($seldb);
                                    while($resultdb = mysql_fetch_array($querydb)){
                                        if($resultdb){
                                            extract($resultdb);
                                            $content=$content;
                                        }
                                    }
                                    //make fckeditor
                                    include_once ('fckeditor/fckeditor.php');
                                    $oFCKeditor = new FCKeditor ( 'desc' );
                                    $oFCKeditor->BasePath = 'fckeditor/';
                                    $oFCKeditor->Width =670;
                                    $oFCKeditor->Height =400;
                                    $oFCKeditor->Value =$content;
                                    $oFCKeditor->Create ();
}

//--------------------------------- chang_pass page -------------------------------------------
function chang_pass (){
    //echo "test12345";
    $submit = $_POST['submit'];
    $date_time_f=date("Y-m-d h:i:s");
    $date_f=date("Y-m-d");
    $time_f=date("h:i:s");
    if($submit){
        //echo "test : $user_fo : $mail : $old_pass : $new_pass :$conf_pass";
        $name_f = strip_tags($_POST['name']);
        $user_fo = strip_tags($_POST['user']);
        $mail_f = strip_tags($_POST['mail']);
        $old_pass = md5(strip_tags($_POST['oldpass']));
        $new_pass = md5(strip_tags($_POST['newpass']));
        $conf_pass = md5(strip_tags($_POST['confpass']));
        $sitename_f = strip_tags($_POST['sitename']);

        if($user_fo == "" && $mail_f == "" && $old_pass == "" && $new_pass == "" && $conf_pass == "" && $name_f == "" && $sitename_f == ""){
            echo "<font color='red'>Sory : من فضلك أدخل البيانات كاملة</font>";
        }elseif($name_f==""){
            echo "<font color='red'>Sory : من فضلك أدخل الاسم</font>";
        }elseif($user_fo==""){
            echo "<font color='red'>Sory :من فضلك ادخل اسم المستخدم</font>";
        }
        elseif($mail_f==""){
            echo "<font color='red'>Sory : من فضلك أدخل البريد</font>";
        }elseif($old_pass==""){
            echo "<font color='red'>Sory : من فضلك أدخل كلمة المرور القديمة</font>";
        }elseif($new_pass==""){
            echo "<font color='red'>Sory : من فضلك أدخل كلمة المرور الجديدة</font>";
        }elseif($conf_pass==""){
            echo "<font color='red'>Sory : من فضلك أدخل كلمة المرور الجديدة مرة أخرى</font>";
        }elseif($new_pass !== $conf_pass){
            echo "<font color='red'>Sory : من فضلك تأكد ان كلمة المرور الجديدة مثل المعادة</font>";
        }elseif($sitename_f==""){
            echo "<font color='red'>Sory : من فضلك أدخل اسم الموقع</font>";
        }else{
            $sel="select * from users";
            $query = mysql_query($sel);
            while($result = mysql_fetch_array($query)){
                extract($result);
            }
            if($user_fo !== $user){
                echo "اسم المستخدم خطأ";
            }elseif($old_pass !== $pass){
                echo "<font color='red'>Sory :كلمة المرور القديمة خطأ!!!</font>";
            }else{
                $update="update users set name='$name_f', sitename='$sitename_f', user='$user_fo', pass='$new_pass', mail='$mail_f', date_time='$date_time_f', date='$date_f', time='$time_f', adm_mem='1', active='1'";
                $qu=mysql_query($update);

                echo "من فضلك انتظر حتى يتم التعديل <img src='images/loading11.gif' />".
                                                "<meta http-equiv='refresh' content='5'>";
            }
        }

    }
}

//--------------------------------- forget_pass page -------------------------------------------
function forget_pass(){
    $submit = $_POST['submit'];

    if($submit){
        //echo "test : $user_fo : $mail : $old_pass : $new_pass :$conf_pass";

        $mail_f = strip_tags($_POST['mail']);

        if($mail_f==""){
            echo "Sory :<br /> please insert E-Mail";
        }else{
            $sel="select * from users";
            $query = mysql_query($sel);
            while($result = mysql_fetch_array($query)){
                extract($result);
            }
            if($mail_f !== $mail){
                echo "<font color='red'>Sory :<br /> البريد خطأ !!!</font>";
            }else{
                $data="الاسم : $name <br /> المستخدم : $user<br /> كلمة المرور : $pass<br />";
                $to="$mail";
                $header="الراسل : لوحة تحكم egaseed<br />";
                $subject = "الان يمكنك تذكر كلمة مرور لوحة تحكم موقع ايجاسيد<br />";
                $message="$data";
                mail($to, $subject, $message , $header);

                echo "<font color='green'><b>Thank You please white...<br /> Now send PassWord Your E_Mail</b></font><br /><img src='images/loading11.gif' />".
                                        "<meta http-equiv='refresh' content='5'>";
            }
        }

    }
}

///////////////////////////////// delete father ////////////////////////////////////////////
//function delete_father(){
//        $sel = "select * from cat";
//        $query = mysql_query($sel);
//        $selrow=mysql_num_rows($query);
//        //Ýí ÍÇáÉ æÌÏ ÇÞÓÇã
//        if($selrow){
//            $self = $_SERVER['PHP_SELF'];
//            echo "<form action='$self' method='post'>";
//                echo "<table>";
//                    echo "<th>اسم القسم</th>";
//                    echo "<th>حذف</th>";
//                    while($result = mysql_fetch_array($query)){
//                        extract($result);
//                        $idd = $result['id'];
//                        echo "<tr>";
//                            echo "<td align='center'>$name</td>";
//                            echo "<td align='center'>
//                                    <input type='checkbox' value='$idd' name='id[]' />
//                                  </td>";
//                        echo "</tr>";
//                    }
//                    echo "<tr>";
//                        echo "<td></td>";
//                        echo "<td align='center'><input type='submit' name='delete' value='حذف' /></td>";
//                    echo "</tr>";
//                echo "</table>";
//            echo "</form>";
//        }else{//Ýí ÍÇáÉ áã íÌÏ Çí ÞÓã
//            echo "<font color='green'>لا توجد أقسام لحذفها</font>";
//        }
//}

///////////////////////////////// show result delete father ////////////////////////////////////////////
//function s_r_d_father(){
//    $delete=$_POST['delete'];
//    $id=$_POST['id'];
//    if($delete){
//        if($id>0){
//            foreach($id as $one_by_one){
//            $query_delete_father=mysql_query('delete from cat where id ='.$one_by_one.'');
//            //you can delete son with father for this cod
//            //$query_delete_son=mysql_query('delete from product where id_cat ='.$one_by_one.'');
//                if($query_delete_father){
//                    echo "<font color='green'><b>please white...<br />Now removing</b></font><br /><img src='images/loading11.gif' />".
//                                        "<meta http-equiv='refresh' content='5'>";
//
//                }
//            }
//        }else{echo "<font color='red'>من فضلك اختر منتج لحذفه!!!";}
//    }
//}

////////////////////////////////////// delete son ////////////////////////////////////////////////
//function delete_son(){
//    $show=$_POST['show'];
//    $sdiv=$_POST['sdiv'];
//    $pathpicprod="../upload/product";
//    //Ýí ÍÇáÉ ÖÛØ ÚÑÖ ÍÓÈ ÇáÇÈ
//    if($show){
//        $sel = "select * from product where id_cat=$sdiv";
//        $query = mysql_query($sel);
//        $resultrow = mysql_num_rows($query);
//            //Ýí ÍÇáÉ æÌÏ ÇÈä
//            if($resultrow > 0){
//            $self = $_SERVER['PHP_SELF'];
//            echo "<form action='$self' method='post'>";
//                echo "<table>";
//                    echo "<th>اسم المنتج</th>";
//                    echo "<th>حذف</th>";
//                    while($result = mysql_fetch_array($query)){
//                        extract($result);
//                        $idd = $result['id'];
//                        echo "<tr>";
//                            echo "<td align='center'>$name - <img src='$pathpicprod/$picname' width='75' height='75' /></td>";
//                            echo "<td align='center'>
//                                    <input type='checkbox' value='$idd' name='id[]' />
//                                  </td>";
//                        echo "</tr>";
//                        echo "<tr>";
//                            echo "<td><hr /></td>";
//                            echo "<td><hr /></td>";
//                        echo "</tr>";
//                    }
//                    echo "<tr>";
//                        echo "<td></td>";
//                        echo "<td align='center'><input type='submit' name='delete' value='حذف' /></td>";
//                    echo "</tr>";
//                echo "</table>";
//            echo "</form>";
//            }else{//Ýí ÍÇáÉ áã íÌÏ ÇÈä
//               echo "<font color='green'>لا توجد منتجات لحذفها</font>";
//            }
//
//    }else{
//        //Ýí ÍÇáÉ ÇáÊÍãíá ÊáÞÇÆí ááÕÝÍÉ íÚÑÖ ÇáãäÊÌÇÊ ßáåÇ
//
//        $sel = "select * from product";
//        $query = mysql_query($sel);
//        $resultrow = mysql_num_rows($query);
//        //Ýí ÍÇáÉ æÌÏ ÇÈä
//        if($resultrow > 0){
//        $self = $_SERVER['PHP_SELF'];
//        echo "<form action='$self' method='post'>";
//            echo "<table>";
//                echo "عرض كل المنتجات<br />";
//                echo "<th>الاسم</th>";
//                echo "<th>حذف</th>";
//                while($result = mysql_fetch_array($query)){
//                    extract($result);
//                    $idd = $result['id'];
//                    echo "<tr>";
//                        echo "<td align='center'>$name - <img src='$pathpicprod/$picname' width='75' height='75' /></td>";
//                        echo "<td align='center'>
//                                <input type='checkbox' value='$idd' name='id[]' />
//                              </td>";
//                    echo "</tr>";
//                    echo "<tr>";
//                        echo "<td><hr /></td>";
//                        echo "<td><hr /></td>";
//                    echo "</tr>";
//                }
//                echo "<tr>";
//                    echo "<td></td>";
//                    echo "<td align='center'><input type='submit' name='delete' value='حذف' /></td>";
//                echo "</tr>";
//            echo "</table>";
//        echo "</form>";
//        }else{
//            //Ýí ÍÇáÉ áã íÌÏ ÇÈä
//            echo "<font color='green'>لا توجد منتجات لحذفها</font>";
//        }
//    }
//
//    //deleting here
//    $delete=$_POST['delete'];
//    $id=$_POST['id'];
//    if($delete){
//        if($id>0){
//            foreach($id as $one_by_one){
//            $query_delete=mysql_query('delete from product where id ='.$one_by_one.'');
//                if($query_delete){
//                    echo "<font color='green'><b>please white...<br />Now removeing</b></font><br /><img src='images/loading11.gif' />".
//                                        "<meta http-equiv='refresh' content='5'>";
//
//                }
//            }
//        }else{echo "<font color='red'>من فضلك اختر منتج لحذفه!!!";}
//    }
//}
//


?>