<?php



include("asl.php");


?>



<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html ; charset=utf-8" />
	<meta http-equiv="content-type" content="text/html" />
	<meta name="author" content="persian" />

	<title>پنل اختصاصی ربات تلگرام گروه توسعه دهندگان AHP</title>
	
	
    <link rel="Stylesheet" type="text/css" href="style.css" />

<style>

  @font-face
{
font-family: 'amir' ;
src:url('font/BKoodakBold.ttf')format('truetype'),
url('font/BKoodakBold.eot')format('eot'),
url('font/BKoodakBold.woff')format('woff');

}
.font{
    font-family:amir;
}

</style>



</head>

<body dir="rtl" align="center" >
<div align="center" >
<?php
//error_reporting(E_ALL);
//ini_set('display_errors', '1');
// import_request_variables("p" , "a_");


//old import
function checkarray($summerarray,$mainkey,$mainarray){
    if(in_array($mainkey, $summerarray)){
        unset($mainarray["$mainkey"]);
        return$mainarray;
    }
    else{
        return"ok";
    }
}

$summerarray=array();
$artest=$_POST;
foreach($artest as $postinfo){

    $ar_mainkey = array_search($postinfo, $artest);
    if(checkarray($summerarray,$ar_mainkey,$artest) != "ok"){
        $artest= checkarray($summerarray,$ar_mainkey,$artest) ;
        $ar_mainkey = array_search($postinfo, $artest);
    }
    ${'a_'.$ar_mainkey} = $postinfo;
    $summerarray[]=$ar_mainkey;
}
//old import


try {
    $conn = new PDO("mysql:host=$servername;dbname=$mydb", $username, $password ,  array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8mb4"));
    // set the PDO error mode to exception

    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    }
catch(PDOException $e)
    {
    echo "Connection failed: " . $e->getMessage();
    }




              $sql = "select * from admin";
                $stmt =   $conn->prepare($sql);
                    $stmt->execute();

                        $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
                         $show =$stmt->fetch()  ;

              $user = $show["user"];
              $pass= $show["pass"];


              $getpass= hash_hmac('md5',$a_pass , salt);


                 if($user == $a_user && $pass == $getpass){
   
  
  
  
  
  
    
 if(!$_FILES['myfile']['name']=="" && $_FILES["myfile"]["error"]==0  ){



      
$ext = end(explode('.',$_FILES['myfile']['name']));

$formats = array('jpg','JPG','gif','GIF','png','PNG','RAR','rar','ZIP','zip','mp4','3gp','mov');
if(!in_array($ext,$formats)){

    print"<p style='color:green' >پسوند معتبر برای آپلود نیست</p>";
    
    }
    elseif( file_exists('upload/'.$_FILES["myfile"]["name"])){
        print"<p style='color:green' >متاسفیم این فایل قبلا اپلود شده لطفا نام ان را تغییر دهید</p>";
      
    }
    elseif( 536870912 < $_FILES["myfile"]["size"]){
        

        print"<p style='color:green' >سایز فایل باید کمتر از نیم گیگ باشد</p>";
    }
    else{
        $path="upload/".$_FILES["myfile"]["name"];
        move_uploaded_file($_FILES["myfile"]["tmp_name"] , $path);
        print"
        <span class='green' >
        اپلود با موفقیت انجام 
        شد
        </span>
        ";
        
    }
  $thenamemyfile1=$_FILES["myfile"]["name"];

    $time=time();

    
    if($a_noa=="edit"){
         $sql = "update products set photo=\"$thenamemyfile1\" where id=\"$a_id\" ";
         $conn->exec($sql); 
    }
    
      
    }
    
    
    
  
  

  
  
   if(!$_FILES['myfile2']['name']=="" && $_FILES["myfile2"]["error"]==0  ){



      
$ext = end(explode('.',$_FILES['myfile2']['name']));

$formats = array('jpg','JPG','gif','GIF','png','PNG','RAR','rar','ZIP','zip','mp4','3gp','mov','ZIP','zip','rar','RAR','PDF','pdf');
if(!in_array($ext,$formats)){

    print"<p style='color:green' >پسوند معتبر برای آپلود نیست</p>";
    
    }
    elseif( file_exists('thefile/'.$_FILES["myfile2"]["name"])){
        print"<p style='color:green' >متاسفیم این فایل قبلا اپلود شده لطفا نام ان را تغییر دهید</p>";
      
    }
    elseif( 536870912 < $_FILES["myfile2"]["size"]){
        

        print"<p style='color:green' >سایز فایل باید کمتر از نیم گیگ باشد</p>";
    }
    else{
        $path="thefile/".$_FILES["myfile2"]["name"];
        move_uploaded_file($_FILES["myfile2"]["tmp_name"] , $path);
        print"
        <span class='green' >
        اپلود با موفقیت انجام 
        شد
        </span>
        ";
        
    }
  $thenamefile2=$_FILES["myfile2"]["name"];

    $time=time();

    
    if($a_noa=="edit"){
         $sql = "update products set fileaddress=\"$thenamefile2\" where id=\"$a_id\" ";
         $conn->exec($sql); 
    }
    
      
    }
  
  
  

    if($a_noa =='delete'){
    
    $sql="delete from  products where id=\"$a_id\" ";
    $conn->exec($sql);


                echo "<p style='color:green' >حذف شد !</p>";
                             
    }
    
    
    
    
if($a_noa == "edit"){
        
                 $sql = "update  products  set id_message1='$id_message1' ,id_message1='$id_message1' ,id_message2='$id_message2' ,id_message3='$id_message3' ,cate='$cate' 
                 where id='$a_id' ";
                 $conn->exec($sql);
                 echo "<p style='color:green' >محصول آپدیت شد</p>";
             
                
    }
    
    if($a_noa == "insert"){
        

        
                $sql="select * from products  ";
        $stmt = $conn->prepare($sql);
        $stmt->execute();
        $stmt->setFetchMode(PDO::FETCH_ASSOC);      
        $getter = $stmt->fetchAll();
        $numrowfusers = $stmt->rowCount();
        $newrow=$numrowfusers + 1; 
        
                $sql = "insert into products(id_message1,id_message2,id_message3,cate) values (
                \"$a_id_message1\",
                \"$a_id_message2\",
                \"$a_id_message3\",
                \"$a_cate\"
                )";
         $conn->exec($sql);
    echo "<p style='color:green' >افزوده شد !</p>";
             
                
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
          
    }




        else{
        
        
        
                      echo "<p style='color:red' >يوزرنيم و يا پسورد اشتباه وارد شده </p><br />
                      <a href='enter.php' target='_blank' >بازگشت به صفحه ی ورود</a>
              
                      ";
                      
     
     
                      function redirect($url){
     if (!headers_sent()){
         header('Location: '.$url); exit;
     }else{
         echo '<script type="text/javascript">';
         echo 'window.location.href="'.$url.'";';
         echo '</script>';
         echo '<noscript>';
         echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
         echo '</noscript>'; exit;
     }
     
     
     
    
     
     
 }
 
  redirect("enter.php");
 
 
 
                      
                      
                      
        }







?>

<h1 class="white">پنل ربات تلگرام AHP</h1>
<br></br>
<h4 class="white">پنل اختصاصی ربات تلگرام نسخه1</h4>
<div id="content" align="right" >
<div id="content-content" >



<br />
<br /> 
<a href="https://telegram.me" target="_blank" >
<input class='button-blue' style="width:725px;" type="button" value="رفتن به داخل ربات" />
</a>

<br />

    <?php

    $sql="select mykey from layertwo  ";
    $stmt = $conn->prepare($sql);
    $stmt->execute();
    $stmt->setFetchMode(PDO::FETCH_ASSOC);
    $allCategories = $stmt->fetchAll();
    $numrowfusers = $stmt->rowCount();
    $newrow=$numrowfusers + 1;



    ?>
<div id="fish">

<table>


 <h5 class='gray'>◄ افزودن محصول جدید</h5>

<form  enctype='multipart/form-data' method='post' action='mahsool.php' >
<table>
<tr>

<th class='th' >id message1</th>
<th class='th'  >id message2</th>


</tr>
<tr>

<td align='center' class='td'  >

    <input placeholder="" type="text" name="id_message1" class="font">

</td>


<td align='center' class='td'  >    <input placeholder="" type="text" name="id_message2" class="font">




<br />




<input  type='hidden' name='user' value="<?php echo $a_user  ?>"  />
<input  type='hidden' name='pass' value="<?php echo $a_pass  ?>" class='font'  />


<input  type='hidden' name='noa' value="insert"  />
</td>




</tr>


<tr>

<th class='th' >id message3</th>
<th class='th'  >cate</th>


</tr>
<tr>
    
    <td  align='center' class='td' >
 <input placeholder="" type="text" name="id_message3" class="font">
</td>

    <td  align='center' class='td' >
  <input placeholder="" type="text" name="cate" class="font">
</td>
</tr>


<tr>



    <td>


        <input type='submit' class='font' value='افزودن'  /> </td>

</tr>

</table>
</form>




   <br />
      <br />
         <br />
            <br />








<hr />
<hr />
<hr />












<h3>محصولات</h3>

<hr /><hr /><hr />







<?php

if($a_noa=="search"){
        $sql="select * from products WHERE name LIKE '$a_filename%'" ;
        print"<p>جست و جو برای  : $a_filename  </p>";
}
else{
    $sql="select * from products  ";
    
}
        $stmt = $conn->prepare($sql);
        $stmt->execute();
        $stmt->setFetchMode(PDO::FETCH_ASSOC);      
        $getter = $stmt->fetchAll();
        $numrowfusers = $stmt->rowCount();
        
        
  print" <h5 class='gray'>◄ تعداد محصولات : $numrowfusers </h5>";

     foreach($getter as $v){
       
 
        
        $id_message1=$v["id_message1"];
        $id_message2=$v["id_message2"];
        $id_message3=$v["id_message3"];
        $cate=$v["cate"];
        $id=$v["id"];
        
        

        



print"
<form  enctype='multipart/form-data' method='post' action='mahsool.php' >
<table>
<tr>

<th class='th' >id message1</th>
<th class='th'  >id message2</th>


</tr>
<tr>

<td align='center' class='td'  >

    <input  type='text' class='font'  name='id_message1'       value=\"$id_message1\"  placeholder=''  />
<td align='center' class='td'  >	

    <input  type='text' class='font'  name='id_message2'       value=\"$id_message2\"  placeholder=''  />

<br />




<input  type='hidden' name='user' value=\"$a_user\"  />
<input  type='hidden' name='pass' value=\"$a_pass\" class='font'  />
<input  type='hidden' name='id' value=\"$id\" class='font'  />
<input  type='hidden' name='noa' value=\"edit\" class='font'  />



</td>




</tr>


<tr>

<th class='th' >id message3</th>
<th class='th'  >cate</th>


</tr>
<tr>
    <td  align='center' class='td' >
    <input  type='text' class='font' name='id message3'  value=\"$id_message3\"  />
</td>

    <td  align='center' class='td' >
    <input  type='text' class='font' name='cate' value=\"$cate\"     />
</td>
</tr>


<tr>




<td> 


<input type='submit' class='font' value='ویرایش'  /> </td>

</tr>

</table>
</form>

    <form method='post' action='mahsool.php' >
    <input  type='hidden' name='user' value=\"$a_user\" />
        <input  type='hidden' name='pass' value=\"$a_pass\"\" class='font'  />
        <input  type='hidden' name='noa' value='delete' class='font'  />
        <input  type='hidden' name='id' value=\"$id\"  />
        <input  type='submit'  value='حذف کن' class='font'  />
    </form>
    </td>
      </form>
<hr /><hr /><hr />


";

     }

?>































<hr />
<hr />
<hr />



<br />
<br />
</div>
   </div>




<a style="text-decoration:none ;" href="http://ahpteam.com" target="_blank" class="gray" >طراحي شده توسط تيم توسعه دهندگان AHP</a>
</div>

<?php
  $conn = null;
?>
</body>
</html>