Просмотр файла partner/modules/guest/admin.php

Размер файла: 4Kb
<?php
Error_Reporting(E_ALL & ~E_NOTICE);
Error_Reporting (ERROR | WARNING);

session_name("SESID");
session_start();
include ("../../config.php");

if ($_GET[act]=="ans")
{
include ("../../themes/$themes.php");
if ($_SESSION[apass]==$apass)
 {
  echo "<p>ответ для $_GET[for]</p>";
  echo "<form action=\"admin.php?act=send&amp;str=$_GET[str]&amp;page=$_GET[page]\" method=\"post\">
        <p><textarea rows=\"4\" cols=\"15\" name=\"otv\"></textarea>";
  echo "<br /><br />";
  if (!empty($_GET[to]))
   {
    echo "<input type=\"radio\" name=\"mail\" value=\"$_GET[to]\">ответ на $_GET[to]<br/><br/>";
   }
  echo "<input type=\"submit\" value=\"ответить\" /></p></form>";  
  echo "<p><a href=\"index.php\">В гостевую</a></p>";
}
else 
{
echo "<p>ошибка авторизации<br/></p>";
}
include ("../../templates/foot.php");
}

if($_GET[act]=="send")
{
 if ($_SESSION[apass]==$apass)
  {
    $otv = $_POST[otv]; 
    $otv = stripslashes($otv);
    $otv = htmlspecialchars($otv);
    # Начало Смайлики ;-)
    $sm_dir = opendir("../../sm");
    while ($file = readdir($sm_dir))
     {
      if($file != "Thumbs.db" && $file != ".." && $file != ".")
       {
        $sm_array[] = "<img src=\"../../sm/$file\" alt=\"\" />";
       }
     }
    closedir ($sm_dir);
    sort($sm_array);
    $sm_dir1 = opendir("../../sm");
    while ($file1 = readdir($sm_dir1))
     {
      if($file1 != "Thumbs.db" && $file1 != ".." && $file1 != ".")
       {
        $file1 = explode(".", $file1);
        $sm_array1[] = ":$file1[0]:";
       }
     }
    sort($sm_array1);
    closedir ($sm_dir1);
    # Конец Смайлики ;-)
    $otv = str_replace($sm_array1,$sm_array,$otv);
    $otv = str_replace('
', '<br/>', $otv);
    $base    = "../../data/gb.txt";
 	$basestr = file("$base");
 	$restr   = trim($basestr[$_GET[str]]);
    $buff    = @file_get_contents($base);
    $buff    = str_replace("$restr\r\n","$restr|$otv\r\n",$buff);
    $file    = fopen("$base","w");
    flock ($file,LOCK_EX);
    fputs($file,"$buff");
    fflush ($file); 
    flock ($file,LOCK_UN);
    fclose($file);
    
  if (!empty($_POST[mail]))
   {
    $headers  = "Content-Type: text/html; charset=utf-8\n";
    $headers .= "From: $emailadmina\nX-Mailer: PHP v.".phpversion();
    $tema     = "Ответ админа из гостевой - $home";
    $text     = "Ответ на ваше сообщение в гостевой - $home: $otv";
    mail($_POST[mail],$tema,$text,$headers);
   }
  header ("Location: index.php?page=$_GET[page]");
  }
   else 
  {
   include ("../../themes/$themes.php");
   echo "<p>ошибка авторизации<br /></p>"; 
   include ("../../templates/foot.php");
  }
}

if ($_GET[act]=="del")
 {
if($_SESSION[apass]==$apass)
   {
   	$basedel = "../../data/gb.txt";
 	$basestr = file("$basedel");
 	$delstr = trim($basestr[$_GET[str]]);
    $buff = @file_get_contents($basedel);
    $buff =str_replace("$delstr\r\n","",$buff);
    $file = fopen("$basedel","w");
    flock ($file,LOCK_EX);
    fputs($file,"$buff");
    fflush ($file); 
    flock ($file,LOCK_UN);
    fclose($file);
    header ("Location: index.php?page=$_GET[page]");
   }
    else 
   {
    include ("../../themes/$themes.php");
    echo "<p>ошибка авторизации<br /></p>"; 
    include ("../../templates/foot.php");
   }
 }
 
if ($_GET[act]=="clearguest")
 {
if($_SESSION[apass]==$apass)
   {
   	$basedel = "../../data/gb.txt";
 	$basestr = file("$basedel");
 	$buff = "$basestr[0]$basestr[1]$basestr[2]$basestr[3]$basestr[4]";
    $file = fopen("$basedel","w");
    flock ($file,LOCK_EX);
    fputs($file,"$buff");
    fflush ($file); 
    flock ($file,LOCK_UN);
    fclose($file);
    header ("Location: index.php");
   }
    else 
   {
    include ("../../themes/$themes.php");
    echo "<p>ошибка авторизации<br /></p>"; 
    include ("../../templates/foot.php");
   }
 }

?>