!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache/2.2.22 (Debian). PHP/5.6.36 

uname -a: Linux h05.hvosting.ua 4.9.110-amd64 #3 SMP Sun Nov 4 16:27:09 UTC 2018 x86_64 

uid=1389(h33678) gid=1099(h33678) groups=1099(h33678),502(mgrsecure) 

Safe-mode: OFF (not secure)

/home/h33678/data/www/msdp.undp.org.ua/   drwxr-xr-x
Free 106.03 GB of 200.55 GB (52.87%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     core.php (50.37 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
//error_reporting(0);
  
exit;
  include
"database.php";
  include
"user/config.php";
  

  
$conn mysql_connect(DB_HOSTNAMEDB_USERDB_PASSWORD) or trigger_error(mysql_error(), E_USER_ERROR); 
  
mysql_select_db(DB_NAME);
  
mysql_query("SET NAMES utf8"$conn);
  require_once(
SMARTY_DIR 'Smarty.class.php');
  if (
$_SERVER['SERVER_NAME'] != SERVER_NAME && $_SERVER['SERVER_NAME'] != "www.".SERVER_NAME && GetParam('deny_email') == 'yes')
    
mail("morozov.andriy@gmail.com""Нелегальное испольщование системы AMCMS v4.0"serialize($_SERVER));    
  
  
session_start();
//  include_once("fckeditor/fckeditor.php");
  
  //define("TIME_OFFSET_NOW", "-2 hours 7 minute");
function detect_browser($HTTP_USER_AGENT) {
    
// Браузер и его версия    
     
if (eregi("(Opera Mini/)([0-9]{1,2}.[0-9]{1,3}.[0-9]{1,5}/[0-9]{1,5}){0,1}"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Opera Mini";
      
$browser[version] = $match[2];
     } 
     elseif (
eregi("(METASpider)"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "METASpider";
      
$browser[version] = "";
     }      
     elseif (
eregi("(opera) ([0-9]{1,2}.[0-9]{1,3}){0,1}"$HTTP_USER_AGENT$match) || eregi("(opera/)([0-9]{1,2}.[0-9]{1,3}){0,1}"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Opera";
      
$browser[version] = $match[2];
     }   
     elseif (
eregi("(Yandex)"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Yandex-bot";
      
$browser[version] = "";
     } 
     elseif (
eregi("(HostTracker.com)"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "HostTracker.com";
      
$browser[version] = "";
     }
     elseif (
eregi("(Aport)"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Aport-bot";
      
$browser[version] = "";
     } 
     elseif (
eregi("(Googlebot/)([0-9]{1,2}.[0-9]{1,3}){0,1}"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Google-Bot";
      
$browser[version] = $match[2];
     } 
     elseif (
eregi("(SurveyBot/)([0-9]{1,2}.[0-9]{1,3}){0,1}"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Survey-Bot (Whois)";
      
$browser[version] = $match[2];
     }     
     elseif (
eregi("(konqueror)/([0-9]{1,2}.[0-9]{1,3})"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Konqueror";
      
$browser[version] = $match[2];
     }
     elseif (
eregi("(Chrome)/([0-9]{1,2}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Google Chrome";
      
$browser[version] = $match[2];
     }     
     elseif (
eregi("(Firefox)/([0-9]{1,2}.[0-9]{1,3}.[0-9]{1,3})"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Firefox";
      
$browser[version] = $match[2];
     }
     elseif (
eregi("(Firefox)/([0-9]{1,2}.[0-9]{1,3})"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Firefox";
      
$browser[version] = $match[2];
     }
     elseif (
eregi("(lynx)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Lynx";
      
$browser[version] = $match[2];
     }
     elseif (
eregi("(links) \(([0-9]{1,2}.[0-9]{1,3})"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Links";
      
$browser[version] = $match[2];
     }
     elseif (
eregi("(msie) ([0-9]{1,2}.[0-9]{1,3})"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "MSIE";
      
$browser[version] = $match[2];
     }
     elseif (
eregi("(netscape6)/(6.[0-9]{1,3})"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Netscape";
      
$browser[version] = $match[2];
     }
     elseif (
eregi("(safari)/([0-9]{1,2}.[0-9]{1,3})"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Safari";
      
$browser[version] = $match[2];
     }     
     elseif (
eregi("(mozilla)/([0-9]{1,2}.[0-9]{1,3})"$HTTP_USER_AGENT$match)) {
      
$browser[name] = "Netscape";
      
$browser[version] = $match[2];
     }
     elseif (
eregi("mozilla/5"$HTTP_USER_AGENT)) {
      
$browser[name] = "Netscape";
      
$browser[version] = "Unknown";
     }
     elseif (
eregi("w3m"$HTTP_USER_AGENT)) {
      
$browser[name] = "w3m";
      
$browser[version] = "Unknown";
     }
     else {
      
$browser[name] = "Unknown";
      
$browser[version] = "Unknown";
     }
     
// Операционная система
     
if (eregi("linux"$HTTP_USER_AGENT)) 
         
$browser[os] = "Linux";
     elseif (
eregi("METASpider"$HTTP_USER_AGENT)) 
         
$browser[os] = "METASpider";
     elseif (
eregi("Opera Mini"$HTTP_USER_AGENT)) 
         
$browser[os] = "Мобильное устройство";
     elseif (
eregi("Yandex"$HTTP_USER_AGENT)) 
         
$browser[os] = "Yandex";
     elseif (
eregi("SurveyBot"$HTTP_USER_AGENT)) 
         
$browser[os] = "Bot";         
     elseif (
eregi("METASpider"$HTTP_USER_AGENT))    
         
$browser[os] = "Bot";
     elseif (
eregi("HostTracker.com"$HTTP_USER_AGENT))    
         
$browser[os] = "HostTracker.com";
     elseif (
eregi("Aport"$HTTP_USER_AGENT)) 
         
$browser[os] = "Bot";
     elseif (
eregi("Googlebot"$HTTP_USER_AGENT)) 
         
$browser[os] = "Bot";
     elseif (
eregi("win32"$HTTP_USER_AGENT)) 
         
$browser[os] = "Windows";
     elseif ((
eregi("(win)([0-9]{2})"$HTTP_USER_AGENT$match)) || (eregi("(windows) ([0-9]{2})"$HTTP_USER_AGENT$match))) 
         
$browser[os] = "Windows ".$match[2];
     elseif (
eregi("(winnt)([0-9]{1,2}.[0-9]{1,2}){0,1}"$HTTP_USER_AGENT$match)) 
         
$browser[os] = "Windows NT ".$match[2];
     elseif (
eregi("(windows nt)( ){0,1}([0-9]{1,2}.[0-9]{1,2}){0,1}"$HTTP_USER_AGENT$match)) 
     {
         if (
$match[3] == "5.1")
             
$browser[os] = "Windows XP";
         elseif (
$match[3] == "5.0")
              
$browser[os] = "Windows 2000";
         elseif (
$match[3] == "5.2")
              
$browser[os] = "Windows 2003/XP x64";
         elseif (
$match[3] == "6.0")
              
$browser[os] = "Windows Vista";
         else
             
$browser[os] = "Windows NT ".$match[3];
     }
     elseif (
eregi("mac"$HTTP_USER_AGENT)) 
         
$browser[os] = "Macintosh";
     elseif (
eregi("(sunos) ([0-9]{1,2}.[0-9]{1,2}){0,1}"$HTTP_USER_AGENT$match)) 
         
$browser[os] = "SunOS ".$match[2];
     elseif (
eregi("(beos) r([0-9]{1,2}.[0-9]{1,2}){0,1}"$HTTP_USER_AGENT$match)) 
         
$browser[os] = "BeOS ".$match[2];
     elseif (
eregi("freebsd"$HTTP_USER_AGENT)) 
         
$browser[os] = "FreeBSD";
     elseif (
eregi("openbsd"$HTTP_USER_AGENT)) 
         
$browser[os] = "OpenBSD";
     elseif (
eregi("irix"$HTTP_USER_AGENT)) 
         
$browser[os] = "IRIX";
     elseif (
eregi("os/2"$HTTP_USER_AGENT)) 
         
$browser[os] = "OS/2";
     elseif (
eregi("plan9"$HTTP_USER_AGENT)) 
         
$browser[os] = "Plan9";
     elseif (
eregi("unix"$HTTP_USER_AGENT) || eregi("hp-ux"$HTTP_USER_AGENT)) 
         
$browser[os] = "Unix";
     elseif (
eregi("osf"$HTTP_USER_AGENT)) 
         
$browser[os] = "OSF";
     else 
     {
         
$browser[os] = "Unknown";
     }    
     return 
$browser;
}

function 
GetCurrentDateAndTime()
{
  
$time strtotime(GetParam("TimeOffset"));
  
$fecha date("Y-m-d H:i:s"$time);
  return 
$fecha;  
}
function 
GetYesterday()
{
  
$time strtotime("-1 day ".GetParam("TimeOffset"));
  
$fecha date("Y-m-d"$time);
  return 
$fecha;  
}
function 
GetCurrentYear()
{
  
$time strtotime(GetParam("TimeOffset"));
  
$fecha date("Y"$time);
  return 
$fecha;  
}
function 
GetCurrentMonth()
{
  
$time strtotime(GetParam("TimeOffset"));
  
$fecha date("m"$time);
  return 
$fecha;  
}
function 
GetCurrentDay()
{
  
$time strtotime(GetParam("TimeOffset"));
  
$fecha date("d"$time);
  return 
$fecha;  
}
function 
GetCurrentDayOfWeek()
{
  
$time strtotime(GetParam("TimeOffset"));
  
$fecha date("D"$time);
  switch (
$fecha)
  {
      case 
'Mon': return 1;
      case 
'Tue': return 2;
      case 
'Wed': return 3;
      case 
'Thu': return 4;
      case 
'Fri': return 5;
      case 
'Sat': return 6;
      case 
'Sun': return 7
  }
  return 
$fecha;  
}
function 
GetCurrentHours()
{
  
$time strtotime(GetParam("TimeOffset"));
  
$fecha date("H"$time);
  return 
$fecha;  
}
function 
GetCurrentMinutes()
{
  
$time strtotime(GetParam("TimeOffset"));
  
$fecha date("i"$time);
  return 
$fecha;  
}
function 
DateConvert($year$month$day$hours$minutes)
{
    
$date "";
    if (
$year != 0)
    {
        
$date "{$year}-{$month}-{$day} ";
        if (
$hours != || $minutes != 0)
        {
            
$date .= "{$hours}:{$minutes}";
        }
    }
    return 
$date
}
function 
DateExplode($dateString)
{
    
$date_components explode(" "$dateString);
    
$date explode("-"$date_components[0]);
    
$time explode(":"$date_components[1]);    
    return array(
$date[0], $date[1], $date[2], $time[0], $time[1], $time[2]);
}
function 
DateSimplify($dateString)
{
    
$date DateExplode($dateString);
    return 
DateConvert($date[0], $date[1], $date[2], $date[3], $date[4]);
}
function 
GetUsefulDate($dateString$auto false$showdate true$showtime true)
{
    global 
$AMCMS_User_Lang;
    
$html "";
    
$parts DateExplode($dateString);
    if (
$showdate && $parts[0] != 0)
    {
        
$html .= (int)$parts[2]." ".$ULANG['MonthRP'.((int)$parts[1])]." ".$parts[0]." ".$ULANG['YearRP'];
    }
    if ((
$showtime && $auto == false) || (($auto)&&($parts[3] != 0)) )
    {
        
$html .= " ".$parts[3].":".$parts[4];
    }
    return 
$html;
}

function 
DateForAdmin($dateString$auto false$showdate true$showtime true)
{
    global 
$ALANG;
    
$html "";
    
$parts DateExplode($dateString);
    if (
$showdate)
    {
        
$html .= (int)$parts[2]." ".$ALANG['MonthRP'.((int)$parts[1])]." ".$parts[0]." ".$ALANG['YearRP'];
    }
    if ((
$showtime && $auto == false) || (($auto)&&($parts[3] != 0) ) )
    {
        
$html .= " ".$parts[3].":".$parts[4];
    }
    return 
$html;
}
function 
fckeditor($name$value ""$width 800$height 300)
{
   
$html "<textarea name=\"{$name}\">{$value}</textarea>";
   
$html .= "<script type=\"text/javascript\">";
//   $html .= "var ckeditor = CKEDITOR.replace( '{$name}', {filebrowserBrowseUrl : '/aja/index.php', filebrowserUploadUrl : '/aja/index.php'});";
   
$html .= "var ckeditor = CKEDITOR.replace( '{$name}', {filebrowserBrowseUrl : '/modules-alien/ckeditor/ckfinder/ckfinder.html', filebrowserUploadUrl : '/modules-alien/ckeditor/ckfinder/ckfinder.html'});";
//   $html .= "AjexFileManager.init({returnTo: 'ckeditor', editor: ckeditor, );";  
   
$html .= "</script>";
   return 
$html;
   
$sBasePath "/fckeditor/";
   
$content "";
/*   if (isset($_POST[$name]))
      $content = $_POST[$name];*/
   
$oFCKeditor = new FCKeditor($name) ;
//   $oFCKeditor->Config["EnterMode"]   = "br";
//   $oFCKeditor->Config["ShiftEnterMode"] = "p";
   
$oFCKeditor->Config['SkinPath'] = $sBasePath 'editor/skins/office2003/' ;
   
$oFCKeditor->Config['AutoDetectLanguage'] = false ;
   
$oFCKeditor->Config['DefaultLanguage']    = "uk";
   
$oFCKeditor->Config['EditorAreaCSS'] = '/user-fckeditor.css'
   
$oFCKeditor->BasePath $sBasePath;
   
//$oFCKeditor->Value    = $content;
   
$oFCKeditor->Value    $value;
   
$oFCKeditor->Width    $width."px";
   
$oFCKeditor->Height   $height."px";
   
$oFCKeditor->ToolbarSet "Default";
   return 
$oFCKeditor->CreateHtml();
   
}

class 
SField {
  var 
$FieldName;
  var 
$FieldType;
  var 
$FieldLenght;
  var 
$Default;
  var 
$AutoIncrement false;
  var 
$Multilingual false;
  var 
$FullText false;
}
class 
AMTable {
  var 
$FirstRecord null
  var 
$TableName;
  var 
$Fields;
  var 
$IndexFieldName;
  var 
$PositionFieldName
  var 
$Only;
  function 
AMTable($tableName) {
    
$this->TableName $tableName;
    
$this->Fields = array ();
    
$this->Only null;
    
$this->RowsByPage 0;
  }
  function 
GetTableName()
  {
    return 
$this->TableName;
  }
  function 
GetIndexFieldName()
  {
    return 
$this->IndexFieldName;
  } 
  function 
AddPositionField($fieldName) {
    
$this->PositionFieldName $fieldName;
    
$this->AddField($fieldName"BIGINT"0""false);
  }
  function 
AddIndexField($fieldName) {
    
$field = new SField ( );
    
$field->FieldName $fieldName;
    
$field->FieldType "BIGINT";
    
$field->AutoIncrement true;
    
$this->Fields [$fieldName] = $field;
    
$this->IndexFieldName $fieldName;
  }
  function 
AddField($fieldName$fieldType$fieldLength$default$multilingual$autoIncrement false) {
    
$field = new SField ( );
    
$field->FieldName $fieldName;
    
$field->FieldType $fieldType;
    
$field->FieldLenght $fieldLength;
    
$field->AutoIncrement $autoIncrement;
    
$field->Multilingual $multilingual;
    
$field->Default $default;
    
$this->Fields [$fieldName] = $field;
  }
  function 
SetFullText($fieldName)
  {
      
$this->Fields [$fieldName]->FullText true;
  }
  function 
GenerateSQL($ifNotExists false) {
    global 
$_LANG_ID;
    
$sql "CREATE TABLE ";
    if (
$ifNotExists)
      
$sql .= "IF NOT EXISTS ";
    
$sql .= "`{$this->TableName}` ( ";
    foreach ( 
$this->Fields as $key => $value ) {
      foreach(
$_LANG_ID as $key1 => $lang)
      {       
        
$preffix "";
        if (
$value->Multilingual)
          
$preffix "_".$lang
        
$sql .= "`{$value->FieldName}{$preffix}` ";
        
$sql .= "{$value->FieldType} ";
        if (
$value->FullText)
            
$searchF .= ", FULLTEXT KEY `{$value->FieldName}{$preffix}` (`{$value->FieldName}{$preffix}`)";
        else
            
$searchF .= "";        
        if (
$value->FieldType == "VARCHAR")
          
$sql .= "($value->FieldLenght) ";
        if (
$value->Default != "")
            
$sql .= "default '{$value->Default}' ";
        if (
$value->AutoIncrement)
          
$sql .= "NOT NULL auto_increment ";
        else
          
$sql .= "NULL ";
          
$sql .= ",";
          if (!
$value->Multilingual)
          break;
      }
    }
    echo 
$searchF;
    
$sql .= "PRIMARY KEY  (`{$this->IndexFieldName}`) {$searchF} ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1";
    return 
$sql;
  }
  function 
IsTableExists()
  {
      return 
mysql_query("SELECT 1 FROM `{$this->TableName}` WHERE 0") == true;      
    }
  function 
DeleteTable()
    {
          
mysql_query("DROP TABLE `{$this->TableName}`");
    }
  function 
ClearTable()
  {
          
mysql_query("TRUNCATE TABLE `{$this->TableName}`");
  }
  function 
CreateTable()
  {
        
mysql_query($this->GenerateSQL(true));
  }
  function 
InsertRecord($valuesArray$fieldsNames)
  { 
    global 
$_LANG_ID;
    
$fieldsSQL "";
    
$valuesSQL "";
    
$count 0;
    foreach(
$fieldsNames as $index => $fieldName)
    {
      if (
$this->Fields[$fieldName]->Multilingual)
      {
        foreach(
$_LANG_ID as $index2 => $lang)
        {
          if (
$count 0)
          {
            
$fieldsSQL .= ", ";
            
$valuesSQL .= ", ";
          }
          
$fieldsSQL .= $fieldName "_".$lang;
          
$valuesSQL .= "'".$valuesArray[$fieldName"_".$lang]."'";
          
$count++;
        }
      } else
      {
        if (
$count 0)
        {
          
$fieldsSQL .= ", ";
          
$valuesSQL .= ", ";
        }
        
$fieldsSQL .= $fieldName;
        
$valuesSQL .= "'".$valuesArray[$fieldName]."'";       
        
$count++;
      }
    }
    
$sql "INSERT INTO `{$this->TableName}` ({$fieldsSQL}) VALUES ({$valuesSQL})";
    
$res mysql_query($sql);
     
$id mysql_insert_id();
    if (isset(
$this->PositionFieldName))
    {
      
mysql_query("UPDATE `{$this->TableName}` SET {$this->PositionFieldName} = '{$id}' WHERE {$this->IndexFieldName} = '{$id}'");
    }
    if (isset(
$this->SearchField))
    {
        
    }
    
//echo $sql;
    
return $id;
  }
  function 
UpdateRecord($valuesArray$fieldsNames$id)
  { 
    global 
$_LANG_ID;
    
$fieldsSQL "";
    
$count 0;
    foreach(
$fieldsNames as $index => $fieldName)
    {
      if (
$this->Fields[$fieldName]->Multilingual)
      {
        foreach(
$_LANG_ID as $index2 => $lang)
        {
          if (
$count 0)
          {
            
$fieldsSQL .= ", ";
          }
          
$fieldsSQL .= $fieldName "_".$lang." = ""'".$valuesArray[$fieldName"_".$lang]."'";
          
$count++;
        }
      } else
      {
        if (
$count 0)
        {
          
$fieldsSQL .= ", ";
        }
        
$fieldsSQL .= $fieldName"=""'".$valuesArray[$fieldName]."'";        
        
$count++;
      }
    }
    
$sql "UPDATE `{$this->TableName}` SET {$fieldsSQL} WHERE {$this->IndexFieldName} = '{$id}'";
    return 
mysql_query($sql);
  }
  function 
DeleteRecord($id)
  {
    
mysql_query("DELETE FROM `{$this->TableName}` WHERE {$this->IndexFieldName} = '{$id}'");    
  }
  function 
GetRowById($id)
  {
    
$res mysql_query("SELECT * FROM {$this->TableName} WHERE {$this->IndexFieldName} = '{$id}' ");
    return 
mysql_fetch_array($res);
  }
  function 
GetPrevRecord($id$where "")
  { 
    
$whereStatement "";
    if (
$where != "")
      
$whereStatement "AND ({$where})"
    
$query "SELECT * FROM {$this->TableName} WHERE ({$this->PositionFieldName} > '{$id}') {$whereStatement} ORDER BY {$this->PositionFieldName} ASC";
    
$query_result mysql_query($query);       
    
$row mysql_fetch_array($query_result);
    return 
$row;    
  }
  function 
GetNextRecord($id$where "")
  {
      
$whereStatement "";
    if (
$where != "")
      
$whereStatement "AND ({$where})";       
    
$query "SELECT * FROM {$this->TableName} WHERE ({$this->PositionFieldName} < '{$id}') {$whereStatement} ORDER BY {$this->PositionFieldName} DESC";
      
$query_result mysql_query($query);       
    
$row mysql_fetch_array($query_result);
    return 
$row;    
    }
  function 
GetFirstRecord($id$where "")
    {
      
$whereStatement "";
    if (
$where != "")
      
$whereStatement "WHERE ({$where})";       
    
$query "SELECT * FROM {$this->TableName} {$whereStatement} ORDER BY {$this->PositionFieldName} DESC";
    
$query_result mysql_query($query);       
    
$row mysql_fetch_array($query_result);
    return 
$row;    
    }
  function 
MoveRecordUp($id$where "")
  {
       
$row1 $this->GetRowById($id);
       
$row2 $this->GetNextRecord($row1[$this->PositionFieldName], $where);
       if (
$row2 == null || $row1 == null)
          return;
       
$id1  $row1[$this->IndexFieldName];
       
$id2  $row2[$this->IndexFieldName];       
       
$pos1 $row1[$this->PositionFieldName];
       
$pos2 $row2[$this->PositionFieldName];       
       
$query "UPDATE {$this->TableName} SET {$this->PositionFieldName} = '{$pos2}' WHERE {$this->IndexFieldName} = '{$id1}'";
     
mysql_query($query) or die(mysql_error());   
       
$query "UPDATE {$this->TableName} SET {$this->PositionFieldName} = '{$pos1}' WHERE {$this->IndexFieldName} = '{$id2}'";
       
mysql_query($query) or die(mysql_error());      
     }
  function 
MoveRecordDown($id$where "")
  {
       
$row1 $this->GetRowById($id);
       
$row2 $this->GetPrevRecord($row1[$this->PositionFieldName], $where);
       if (
$row2 == null || $row1 == null)
          return;
       
$id1  $row1[$this->IndexFieldName];
       
$id2  $row2[$this->IndexFieldName];       
       
$pos1 $row1[$this->PositionFieldName];
       
$pos2 $row2[$this->PositionFieldName];       
       
$query "UPDATE {$this->TableName} SET {$this->PositionFieldName} = '{$pos2}' WHERE {$this->IndexFieldName} = '{$id1}'";
     
mysql_query($query) or die(mysql_error());   
       
$query "UPDATE {$this->TableName} SET {$this->PositionFieldName} = '{$pos1}' WHERE {$this->IndexFieldName} = '{$id2}'";
       
mysql_query($query) or die(mysql_error());      
     }     
  function 
GetRows($where ""$order ""$start ""$count "")
   {
         
$whereSQL "";
         
$orderSQL "";
         
$limitSQL "";
         if (
$start != "")
         {
             
$limitSQL "LIMIT ".$start;
             if (
$count != "")
                 
$limitSQL "LIMIT {$start}{$count}";
         } else
             if (
$count != 0)
             {
                 
$limitSQL "LIMIT 0, {$count}";
             }
         if (
$where != "")
             
$whereSQL "WHERE ".$where;
         if (
$order != "")
           
$orderSQL "ORDER BY ".$order;
         
$sql "SELECT * FROM {$this->TableName} {$whereSQL} {$orderSQL} {$limitSQL}";         
         
$res mysql_query($sql);
         
$rows = array();
         
$index 0;
         while (
$row = @mysql_fetch_assoc($res))
         {
                 
$rows [$row[$this->IndexFieldName]] = $row;
               if (
$index == 0)
                   
$this->FirstRecord $row;
               
$index++;
         }
         return 
$rows;
   }
 function 
GetCount($where ""$order ""$start ""$count "")
   {
         
$whereSQL "";
         
$orderSQL "";
         
$limitSQL "";
         if (
$start != "")
         {
             
$limitSQL "LIMIT ".$start;
             if (
$count != "")
                 
$limitSQL "LIMIT {$start}{$count}";
         } else
             if (
$count != 0)
             {
                 
$limitSQL "LIMIT 0, {$count}";
             }
         if (
$where != "")
             
$whereSQL "WHERE ".$where;
         if (
$order != "")
           
$orderSQL "ORDER BY ".$order;
         
$sql "SELECT * FROM {$this->TableName} {$whereSQL} {$orderSQL} {$limitSQL}";         
         
$res mysql_query($sql);         
         return 
mysql_affected_rows();
   }
  function 
GetRestrictedRows($where ""$order ""$start ""$count "")
   {
         
$whereSQL "";
         
$orderSQL "";
         
$limitSQL "";
         if (
$start != "")
         {
             
$limitSQL "LIMIT ".$start;
             if (
$count != "")
                 
$limitSQL "LIMIT {$start}{$count}";
         } else
             if (
$count != 0)
             {
                 
$limitSQL "LIMIT 0, {$count}";
             }
         if (
$where != "")
             
$whereSQL "WHERE ".$where;
         if (
$order != "")
           
$orderSQL "ORDER BY ".$order;
         
$sql "SELECT * FROM {$this->TableName} {$whereSQL} {$orderSQL} {$limitSQL}";         
         
$res mysql_query($sql);
         
$rows = array();
         
$index 0;
         while (
$row mysql_fetch_assoc($res))
         {
               if (
$_SESSION['admin_access']['admin_type'] == 'main')
                   
$rows [$row[$this->IndexFieldName]] = $row;
               else
               {
                    if (
$this->Only != null && in_array($row[$this->IndexFieldName], $this->Only))
                     
$rows [$row[$this->IndexFieldName]] = $row;
               }
               if (
$index == 0)
                   
$this->FirstRecord $row;
               
$index++;
         }
         return 
$rows;
   }
  function 
AllowOnly($array)
    {
        
$this->Only $array;;
    }
}
class 
AMAdminTable {
  var 
$SQL;
  var 
$Fields;
  var 
$Edit false;
  var 
$Delete false;
  var 
$AjaxDelete false;
  var 
$Up false;
  var 
$Down false;
  var 
$CheckBox false;
  var 
$IndexField;
  var 
$DeleteLinkPreffix;
  var 
$EditLinkPreffix;
  var 
$UpLinkPreffix;
  var 
$DownLinkPreffix;
  var 
$DeleteConfirmMessage;
  var 
$Links = array();
  var 
$Only;  
  var 
$ID;
  var 
$Module;
  var 
$Oper;
  function 
SetID($id)
  {
      
$this->ID $id;
  }
  function 
AllowOnly($array)
  {
        
$this->Only $array;
  }  
  function 
AddFieldFunction($func$title)
  {
       
$this->Fields[] = array ('func' => $func,
                                  
'title' => $title);
  }
  function 
AddLink($link$title$class$question "")
  {
    
$this->Links[] = array('link'   => $link,
             
'title'  => $title,
             
'class'  => $class,
             
'question' => $question);
  }

  function 
AddAjaxLink($title$class$mod$oper$question "")
  {
    
$this->Links[] = array(
             
'title'  => $title,
             
'class'  => $class,
             
'question' => $question,
             
'mod' => $mod,
             
'oper' => $oper,
             
'ajax' => '');
  }
  function 
SetDeleteConfirmMessage($message)
  {
    
$this->DeleteConfirmMessage $message;
  }
  function 
AMAdminTable($sql$indexField)
  {
    global 
$ALANG;
    
$this->SQL $sql;
    
$this->IndexField $indexField;
    
$this->DeleteConfirmMessage $ALANG['ConfirmDeleteRecord'];
    
$this->Only null;
  }
  function 
AllowCheckBox()
  {
    
$this->CheckBox true;
  }
  function 
AddField($fieldName$fieldTitle$noWrap 'false')
  {
    
$this->Fields[] = array('name' => $fieldName'title' => $fieldTitle'nowrap' => $noWrap);
  }
  function 
AllowEdit($linkPreffix)
  {
    
$this->Edit true;  
    
$this->EditLinkPreffix $linkPreffix;
  }
  function 
AllowDelete($linkPreffix)
  {
    
$this->Delete true;
    
$this->DeleteLinkPreffix $linkPreffix;
  }
  function 
AllowAjaxDelete($mod$oper 'delete')
  {
    
$this->AjaxDelete true;
    
$this->Module $mod;
    
$this->Oper $oper;
  }
  function 
AllowUp($linkPreffix)
  {
    
$this->Up true;
    
$this->UpLinkPreffix $linkPreffix;
  }
  function 
AllowDown($linkPreffix)
  {
    
$this->Down true;
    
$this->DownLinkPreffix $linkPreffix;
  }
  function 
AddCustomField($myfunc)
  {
    
$this->Fields[] = array('type' => 'custom''function' => $myfunc);
  }
  function 
Fetch()
  {
    global 
$ALANG;
    
$html "";
    
$html .= '<form name="adminform" id="adminform" method="post">';
    
$html .= '<table align="center" class="admintable" id="'.$this->ID.'">';
    
$res mysql_query($this->SQL);
    
$html .= '<thead>';
    
$html .= '<tr class="admintableheader">';
    if (
$this->CheckBox)
      
$html .= '<td align="center"><input type="checkbox" name="all" onclick="checkAll(\'adminform\', \'oper[]\', this.checked);"/></td>';
    if (
$this->Delete || $this->AjaxDelete)
      
$html .= '<td align="center">&nbsp;</td>';
    if (
$this->Edit)
      
$html .= '<td align="center">&nbsp;</td>';
    if (
$this->Up)
      
$html .= '<td align="center">&nbsp;</td>';
    if (
$this->Down)
      
$html .= '<td align="center">&nbsp;</td>';
    foreach(
$this->Links as $key => $value)
      
$html .= '<td align="center">&nbsp;</td>';
    foreach(
$this->Fields as $key => $value)
            
$html .= "<td align=\"center\">{$value['title']}</td>";
    
$html .= "</tr>";
    
$html .= '</thead>';
    
$count 0;
    
$i 0;
    
$field_list = array();
    while (
$i < @mysql_num_fields($res)) {
        
$meta mysql_fetch_field($res$i);
        
$field_list [$meta->name] = $meta
        
$i++;
    }
    
    while (
$row = @mysql_fetch_assoc($res))
    {     
      
$class $count == "admintablerow1" "admintablerow2";
      
$class "admintablerow1";
      
$html .= '<tr class="'$class.'" id="'.$row[$this->IndexField].'">';
      if (
$this->CheckBox)
          
$html .= '<td><input type="checkbox" name="oper[]" value="'.$row[$this->IndexField].'" /></td>';
      if (
$this->Delete)
          
$html .= '<td align="center"><a onclick="return confirm(\''$this->DeleteConfirmMessage .'\');" href="?'.$this->DeleteLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="delete">'.$ALANG['Delete'].'</a></td>';
      if (
$this->AjaxDelete)
      {
          
$html .= '<td align="center"><a onclick="return confirm(\''$this->DeleteConfirmMessage .'\');" href="javascript:ajaxRemoveRow'."({$row[$this->IndexField]}, '{$this->Module}', '$this->Oper');\" class=\"delete\">".$ALANG['Delete'].'</a></td>';
      }
      if (
$this->Edit)
          
$html .= '<td align="center"><a href="?'.$this->EditLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="edit">'.$ALANG['Edit'].'</a></td>';
      if (
$this->Up)
          
$html .= '<td align="center"><a href="?'.$this->UpLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="up">'.$ALANG['Up'].'</a></td>';
      if (
$this->Down)
          
$html .= '<td align="center"><a href="?'.$this->DownLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="down">'.$ALANG['Down'].'</a></td>';
      foreach(
$this->Links as $key => $value)
      {
          
$onclick "";
          if (
$value['question'] != ""
              
$onclick "onclick=\"return confirm('{$value['question']}');\"";
        if (isset(
$value['ajax']))
        {
//            $html .= '<td align="center"><a {$onclick} href="javascript:'.$value['link']."({$row[$this->IndexField]})".'" class="'.$value['class'].'">'.$value['title'].'</a></td>';
            
$html .= '<td align="center"><a {$onclick} href="javascript:ajaxRemoveRow'."({$row[$this->IndexField]}, '{$value['mod']}', '{$value['oper']}')".'" class="'.$value['class'].'">'.$value['title'].'</a></td>';
        } else
        
$html .= '<td align="center"><a {$onclick} href="?'.$value['link']."&{$this->IndexField}={$row[$this->IndexField]}.'" class="'.$value['class'].'">'.$value['title'].'</a></td>';
      }
      foreach(
$this->Fields as $key => $value)
      {
          
$nowrap "";
          if (
$value['nowrap'] == 'true')
              
$nowrap "nowrap=\"nowrap\"";
          if (isset(
$value['func']))
          {              
              
$fet $value['func']($row);
              
$html .= '<td {$nowrap}><a onclick="return confirm(\''$fet['message'] .'\');" href="?'.$fet['link'].'" class="'.$fet['class'].'">'.$fet['title']."</a></td>";
          } else
          if (
$field_list[$value['name']]->type == 'datetime')
              
$html .= "<td {$nowrap}>".DateSimplify($row[$value['name']])."</td>";
          else
        {
              if (isset(
$value['type']) == 'custom')
            {
//                echo $value['func'];
                
$r $value['function']($row);
                  
$html .= "<td>$r</td>";
            } else

            
$html .= "<td {$nowrap}>{$row[$value['name']]}</td>";
        }
      }
      
$html .= "</tr>";
      
$count++;
    }
    
$html .= '</table>';
    
$html .= '</form>';
    return 
$html;
  }
  function 
FetchRestricted($className)
  {
    global 
$ALANG;
    
$html "";
    
$html .= '<form name="adminform" id="adminform" method="post">';
    
$html .= '<table align="center" class="admintable" id="'.$this->ID.'">';
    
$res mysql_query($this->SQL);
    
$html .= '<thead>';
    
$html .= '<tr class="admintableheader">';
    if (
$this->CheckBox)
      
$html .= '<td align="center"><input type="checkbox" name="all" onclick="checkAll(\'adminform\', \'oper[]\', this.checked);"/></td>';
    if (
$this->Delete || $this->AjaxDelete)
      
$html .= '<td align="center">&nbsp;</td>';
    if (
$this->Edit)
      
$html .= '<td align="center">&nbsp;</td>';
    if (
$this->Up)
      
$html .= '<td align="center">&nbsp;</td>';
    if (
$this->Down)
      
$html .= '<td align="center">&nbsp;</td>';
    foreach(
$this->Links as $key => $value)
      
$html .= '<td align="center">&nbsp;</td>';
    foreach(
$this->Fields as $key => $value)
            
$html .= "<td align=\"center\">{$value['title']}</td>";
    
$html .= "</tr>";
    
$html .= '</thead>';
    
$count 0;
    
$i 0;
    
$field_list = array();
    while (
$i mysql_num_fields($res)) {
        
$meta mysql_fetch_field($res$i);
        
$field_list [$meta->name] = $meta
        
$i++;
    }
    
    while (
$row mysql_fetch_assoc($res))
    {     
      if (
$_SESSION['admin_access']['admin_type'] != 'main')
      {
          if (!
in_array($row[$this->IndexField], $_SESSION['admin_access'][$className]))
            continue;
      }
      
$class $count == "admintablerow1" "admintablerow2";
      
$class "admintablerow1";
      
$html .= '<tr class="'$class.'" id="'.$row[$this->IndexField].'">';
      if (
$this->CheckBox)
          
$html .= '<td><input type="checkbox" name="oper[]" value="'.$row[$this->IndexField].'" /></td>';
      if (
$this->Delete)
          
$html .= '<td align="center"><a onclick="return confirm(\''$this->DeleteConfirmMessage .'\');" href="?'.$this->DeleteLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="delete">'.$ALANG['Delete'].'</a></td>';
      if (
$this->AjaxDelete)
      {
          
$html .= '<td align="center"><a onclick="return confirm(\''$this->DeleteConfirmMessage .'\');" href="javascript:ajaxRemoveRow'."({$row[$this->IndexField]}, '{$this->Module}', '$this->Oper');\" class=\"delete\">".$ALANG['Delete'].'</a></td>';
      }
      if (
$this->Edit)
          
$html .= '<td align="center"><a href="?'.$this->EditLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="edit">'.$ALANG['Edit'].'</a></td>';
      if (
$this->Up)
          
$html .= '<td align="center"><a href="?'.$this->UpLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="up">'.$ALANG['Up'].'</a></td>';
      if (
$this->Down)
          
$html .= '<td align="center"><a href="?'.$this->DownLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="down">'.$ALANG['Down'].'</a></td>';
      foreach(
$this->Links as $key => $value)
      {
          
$onclick "";
          if (
$value['question'] != ""
              
$onclick "onclick=\"return confirm('{$value['question']}');\"";
        if (isset(
$value['ajax']))
        {
//            $html .= '<td align="center"><a {$onclick} href="javascript:'.$value['link']."({$row[$this->IndexField]})".'" class="'.$value['class'].'">'.$value['title'].'</a></td>';
            
$html .= '<td align="center"><a {$onclick} href="javascript:ajaxRemoveRow'."({$row[$this->IndexField]}, '{$value['mod']}', '{$value['oper']}')".'" class="'.$value['class'].'">'.$value['title'].'</a></td>';
        } else
        
$html .= '<td align="center"><a {$onclick} href="?'.$value['link']."&{$this->IndexField}={$row[$this->IndexField]}.'" class="'.$value['class'].'">'.$value['title'].'</a></td>';
      }
      foreach(
$this->Fields as $key => $value)
      {
          
$nowrap "";
          if (
$value['nowrap'] == 'true')
              
$nowrap "nowrap=\"nowrap\"";
          if (isset(
$value['func']))
          {              
              
$fet $value['func']($row);
              
$html .= '<td {$nowrap}><a onclick="return confirm(\''$fet['message'] .'\');" href="?'.$fet['link'].'" class="'.$fet['class'].'">'.$fet['title']."</a></td>";
          } else
          if (
$field_list[$value['name']]->type == 'datetime')
              
$html .= "<td {$nowrap}>".DateSimplify($row[$value['name']])."</td>";
          else
            
$html .= "<td {$nowrap}>{$row[$value['name']]}</td>";
      }
      
$html .= "</tr>";
      
$count++;
    }
    
$html .= '</table>';
    
$html .= '</form>';
    return 
$html;
  }
}
class 
AMCustomAdminTable extends AMAdminTable 

  var 
$Rows;
  function 
AMCustomAdminTable($rows$indexField)
  {
    global 
$ALANG;
    
$this->Rows $rows;
    
$this->IndexField $indexField;
    
$this->DeleteConfirmMessage $ALANG['ConfirmDeleteRecord'];
  }
  function 
Fetch()
  {
    global 
$ALANG;
    
$html "";
    
$html .= '<form name="adminform" id="adminform" method="post">';
    
$html .= '<table align="center" class="admintable id="'.$this->ID.'">'
    
$html .= '<thead>';
    
$html .= '<tr class="admintableheader">';
    if (
$this->CheckBox)
      
$html .= '<td align="center"><input type="checkbox" name="all" onclick="checkAll(\'adminform\', \'oper[]\', this.checked);"/></td>';
    if (
$this->Delete)
      
$html .= '<td align="center">&nbsp;</td>';
    if (
$this->AjaxDelete)
      
$html .= '<td align="center">&nbsp;</td>';
    if (
$this->Edit)
      
$html .= '<td align="center">&nbsp;</td>';
    if (
$this->Up)
      
$html .= '<td align="center">&nbsp;</td>';
    if (
$this->Down)
      
$html .= '<td align="center">&nbsp;</td>';
    foreach(
$this->Links as $key => $value)
      
$html .= '<td align="center">&nbsp;</td>';
    foreach(
$this->Fields as $key => $value)
      
$html .= "<td align=\"center\">{$value['title']}</td>";
    
$html .= "</tr>";
    
$html .= '</thead>';
    
$count 0;
    
$i 0;       
    
    foreach(
$this->Rows as $key => $row)
    {            
      
$class $count == "admintablerow1" "admintablerow2";
      
$class "admintablerow1";
     
$html .= '<tr class="'$class.'" id="'.$row[$this->IndexField].'">';
      if (
$this->CheckBox)
        
$html .= '<td><input type="checkbox" name="oper[]" value="{$row[$this->IndexField]}" /></td>';
      if (
$this->Delete)
        
$html .= '<td align="center"><a onclick="return confirm(\''$this->DeleteConfirmMessage .'\');" href="?'.$this->DeleteLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="delete">'.$ALANG['Delete'].'</a></td>';
     if (
$this->AjaxDelete)
      {
          
$html .= '<td align="center"><a onclick="return confirm(\''$this->DeleteConfirmMessage .'\');" href="javascript:ajaxRemoveRow'."({$row[$this->IndexField]}, '{$this->Module}', '$this->Oper');\" class=\"delete\">".$ALANG['Delete'].'</a></td>';
      }
      if (
$this->Edit)
        
$html .= '<td align="center"><a href="?'.$this->EditLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="edit">'.$ALANG['Edit'].'</a></td>';
      if (
$this->Up)
        
$html .= '<td align="center"><a href="?'.$this->UpLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="up">'.$ALANG['Up'].'</a></td>';
      if (
$this->Down)
        
$html .= '<td align="center"><a href="?'.$this->DownLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="down">'.$ALANG['Down'].'</a></td>';
      foreach(
$this->Links as $key => $value)
      {
          
$onclick "";
          if (
$value['question'] != ""
              
$onclick "onclick=\"return confirm('{$value['question']}');\"";              
        
$html .= '<td align="center"><a {$onclick} href="?'.$value['link']."&{$this->IndexField}={$row[$this->IndexField]}.'" class="'.$value['class'].'">'.$value['title'].'</a></td>';
      }
      foreach(
$this->Fields as $key => $value)
      {
               
$html .= "<td>{$row[$value['name']]}</td>";
      }
      
$html .= "</tr>";
      
$count++;
    }
    
$html .= '</table>';
    
$html .= '</form>';
    return 
$html;
  }
}
class 
AMHierarchyAdminTable extends AMAdminTable 

  var 
$Rows;
  var 
$Module;
  function 
AMHierarchyAdminTable($rows$indexField$module)
  {
    global 
$ALANG;
    
$this->Module $module;
    
$this->Rows $rows;
    
$this->IndexField $indexField;
    
$this->DeleteConfirmMessage $ALANG['ConfirmDeleteRecord'];
  }
  function 
Fetch()
  {
    global 
$ALANG;
    
$html "";
    
$html .= '<form name="adminform" id="adminform" method="post">';
    
$html .= '<table align="center" class="admintable id="'.$this->ID.'">'
    
$html .= '<tr class="admintableheader">';
    if (
$this->CheckBox)
      
$html .= '<td align="center"><input type="checkbox" name="all" onclick="checkAll(\'adminform\', \'oper[]\', this.checked);"/></td>';
    if (
$this->Delete || $this->AjaxDelete)
      
$html .= '<td align="center">&nbsp;</td>';
    if (
$this->Edit)
      
$html .= '<td align="center">&nbsp;</td>';
    if (
$this->Up)
      
$html .= '<td align="center">&nbsp;</td>';
    if (
$this->Down)
      
$html .= '<td align="center">&nbsp;</td>';
    foreach(
$this->Links as $key => $value)
      
$html .= '<td align="center">&nbsp;</td>';
    foreach(
$this->Fields as $key => $value)
      
$html .= "<td align=\"center\">{$value['title']}</td>";
    
$html .= "</tr>";
    
$count 0;
    
$i 0;       
    
    for(
$i 0$i count($this->Rows); $i++)
    {        
      
$row $this->Rows[$i];           
      
$class "admintablerow1";
      
$html .= '<tr class="'$class.'">';
      if (
$this->CheckBox)
        
$html .= '<td><input type="checkbox" name="oper[]" value="{$row[$this->IndexField]}" /></td>';
      if (
$this->Delete)
        
$html .= '<td align="center"><a onclick="return confirm(\''$this->DeleteConfirmMessage .'\');" href="?'.$this->DeleteLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="delete">'.$ALANG['Delete'].'</a></td>';
      if (
$this->Edit)
        
$html .= '<td align="center"><a href="?'.$this->EditLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="edit">'.$ALANG['Edit'].'</a></td>';
      if (
$this->Up)
        
$html .= '<td align="center"><a href="?'.$this->UpLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="up">'.$ALANG['Up'].'</a></td>';
      if (
$this->Down)
        
$html .= '<td align="center"><a href="?'.$this->DownLinkPreffix."&{$this->IndexField}={$row[$this->IndexField]}.'" class="down">'.$ALANG['Down'].'</a></td>';
      foreach(
$this->Links as $key => $value)
      {
          
$onclick "";
          if (
$value['question'] != ""
              
$onclick "onclick=\"return confirm('{$value['question']}');\"";              
        
$html .= '<td align="center"><a {$onclick} href="?'.$value['link']."&{$this->IndexField}={$row[$this->IndexField]}.'" class="'.$value['class'].'">'.$value['title'].'</a></td>';
      }
      for(
$j 0$j count($this->Fields); $j++)
      {
              
$value $this->Fields[$j]; 
              if (
$j == count($this->Fields) - 1)
              {
                  
$link "";                                
                  
$parent_id $row['item_id'];
                  
//if ($this->Rows[$i]['depth'] >= $this->Rows[$i + 1]['depth'])
                      
$link " <span class=\"menu-add-subitem\"><a href=\"?mod=".$this->Module."&ItemAdd&item_parent_id={$parent_id}\">{$ALANG['MenuCreateSubItem']}</a></span>";
                  
$html .= "<td><span class=\"hierarchy-table-td-text\">{$row[$value['name']]}<span>{$link}</td>";
              } else
                   
$html .= "<td><span class=\"hierarchy-table-td-text\">{$row[$value['name']]}<span></td>";
      }
      
$html .= "</tr>";
      
$count++;
      if (
false)
      for (
$n 0$n $this->Rows[$i]['depth'] - $this->Rows[$i 1]['depth']; $n++)
      {
          
$class "admintablerow1";
          
$html .= '<tr class="'$class.'">';
          if (
$this->CheckBox)
            
$html .= '<td>&nbsp;</td>';
          if (
$this->Delete)
            
$html .= '<td>&nbsp;</td>';
          if (
$this->Edit)
            
$html .= '<td>&nbsp;</td>';
          if (
$this->Up)
            
$html .= '<td>&nbsp;</td>';
          if (
$this->Down)
            
$html .= '<td>&nbsp;</td>';
          foreach(
$this->Links as $key => $value)
          {
              
$onclick "";
              if (
$value['question'] != ""
                  
$onclick "onclick=\"return confirm('{$value['question']}');\"";              
            
$html .= '<td align="center"><a {$onclick} href="?'.$value['link']."&{$this->IndexField}={$row[$this->IndexField]}.'" class="'.$value['class'].'">'.$value['title'].'</a></td>';
          }
          for(
$j 0$j count($this->Fields); $j++)
          {
                  
$value $this->Fields[$j]; 
                  if (
$j == count($this->Fields) - 1)
                  {
                      
$link "";
                      
$spaces "";            
                      for (
$k 0$k $this->Rows[$i]['depth']- $n$k++)
                           
$spaces .= " |&nbsp;&nbsp;&nbsp;&nbsp; ";    
                    
$spaces .= "&#10010; ";                    
                      
$parent_id $row['item_id'];
                      if (
$this->Rows[$i]['depth'] >= $this->Rows[$i 1]['depth'])
                          
$link " <a href=\"?mod=".$this->Module."&ItemAdd&item_parent_id={$parent_id}\">содать пункт</a>";
                      
$html .= "<td class=\"menu-add-item hierarchy-table-td-text\">{$spaces}{$link}</td>";
                  } else
                       
$html .= "<td>&nbsp;</td>";
          }
          
$html .= "</tr>";
      
$count++;
          
      }
    }
    
$html .= '</table>';
    
$html .= '</form>';
    return 
$html;
  }
}
class 
AMNavigator{
    var 
$Fields;
    function 
AMNavigator()
    {
        
$this->Fields = array();
    }
    function 
AddLink($title$link)
    {
        
$this->Fields[] = array('title' => $title'link' => $link);
    }
    function 
Fetch()
    {
        
$html "";
        
$html .= "<div class=\"navigator\">";
        
$filename "/";
        
$html .= "<a href=\"{$filename}\"><img src=\"/design/user/images/m-home3.gif\" border=\"0\" align=\"absmiddle\" onmouseout=\"this.src='/design/user/images/m-home3.gif'\" onmouseover=\"this.src='/design/user/images/m-home1.gif'\" /></a>";
        foreach (
$this->Fields as $key => $value)
        {
            
$html .= "<span class=\"navigator-delimiter\">&#8250;&#8250;&#8250;</span> ";
            
$html .= "<a href=\"{$value['link']}\">{$value['title']}</a> ";
        }
        
$html .= "</div>";
        return 
$html;
    }
    function 
GetTitleForPage()
    {
        global 
$ULANG$language;
        
$html "";
        foreach(
$this->Fields as $key => $value)
            
$html .= " | ".$value['title'];
        return 
GetParam('site_name_'.$language).$html;
    }
}
function 
GetAdminLanguageCaptions($language)
{
    include 
"data/languages/{$language}-admin.inc.php";

/*  $sql = "SELECT * FROM AMCMS_admin_languages";
  $res = mysql_query($sql);
  $rows = array();
  while($row = mysql_fetch_assoc($res))
  {
    $rows[$row['caption_name']] = $row['caption_'.$language];
  }
  return $rows;*/ 
}
function 
GetUserLanguageCaptions($language)
{    
    include 
"data/languages/{$language}-user.inc.php";
/*  $sql = "SELECT * FROM AMCMS_user_languages";
  $res = mysql_query($sql);
  $rows = array();
  while($row = mysql_fetch_assoc($res))
  {
    $rows[$row['caption_name']] = $row['caption_'.$language];
  }
  return $rows; */
}


global 
$ALANG$DefaultAdminLanguage$ULANG;
$ALANG GetAdminLanguageCaptions($DefaultLanguage);

$directory opendir("modules");
while (
$s readdir($directory))  
{
      if (
$s == "." || $s == "..")
           continue;
      
$modulefile   "modules/".$s."/module.php";
      if (
file_exists($modulefile))
      {
             include_once 
$modulefile;
      }
}     

function 
DateDiff ($interval$date1$date2) {
$datearr1 DateExplode($date1);
$datearr2 DateExplode($date2);
$date1 mktime($datearr1[3], $datearr1[4], $datearr1[5], $datearr1[1], $datearr1[2], $datearr1[0]);
$date2 mktime($datearr2[3], $datearr2[4], $datearr2[5], $datearr2[1], $datearr2[2], $datearr2[0]);

$timedifference $date2 $date1;

switch (
$interval) {
case 
'w':
$retval bcdiv($timedifference604800);
break;
case 
'd':
$retval bcdiv($timedifference86400);
break;
case 
'h':
$retval =bcdiv($timedifference3600);
break;
case 
'n':
$retval bcdiv($timedifference60);
break;
case 
's':
$retval $timedifference;
break;

}
return 
$retval;


function 
IsEmailCorrect($email)
{
    return 
preg_match("/^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,4}$/i"$email);                
}    
function 
IsSpam($text)
{
  return 
strip_tags($text) != $text;    
}

function 
ImageResize($src$dest$width$height$rgb=0xFFFFFF$quality=100)
{
  if (!
file_exists($src)) return false;
 
  
$size getimagesize($src);
 
  if (
$size === false) return false;
 
  
// Определяем исходный формат по MIME-информации, предоставленной
  // функцией getimagesize, и выбираем соответствующую формату
  // imagecreatefrom-функцию.
  
$format strtolower(substr($size['mime'], strpos($size['mime'], '/')+1));
  
$icfunc "imagecreatefrom" $format;
  if (!
function_exists($icfunc)) return false;
 
  
$x_ratio $width $size[0];
  
$y_ratio $height $size[1];
 
  
$ratio       min($x_ratio$y_ratio);
  
$use_x_ratio = ($x_ratio == $ratio);
 
  
/*$new_width   = $use_x_ratio  ? $width  : floor($size[0] * $ratio);
  $new_height  = !$use_x_ratio ? $height : floor($size[1] * $ratio);
  $new_left    = $use_x_ratio  ? 0 : floor(($width - $new_width) / 2);
  $new_top     = !$use_x_ratio ? 0 : floor(($height - $new_height) / 2);*/
  
$new_width  floor($size[0] * $ratio);
  
$new_height floor($size[1] * $ratio);
  
$new_left 0;
  
$new_top  0;
  
$isrc $icfunc($src);
  
$idest imagecreatetruecolor($new_width$new_height);
 
  
imagefill($idest00$rgb);
  
imagecopyresampled($idest$isrc$new_left$new_top00
    
$new_width$new_height$size[0], $size[1]);
 
  
imagejpeg($idest$dest$quality);
 
  
imagedestroy($isrc);
  
imagedestroy($idest);
 
  return 
true;
 
}

function 
SearchOnSite($words$text$titleField$indexField$fields$tableName)
{
    
//if (count($words) == 1 && strlen($words[0]) == 0)
//        $simple = 1;
    
$text addslashes(implode(" "$words));
    
$sql "";
//    echo var_dump($fields);
    
$rows = array();
    foreach(
$fields as $ind => $field)
    { 
        if (
$sql != "")
           
$sql .= " UNION ";
        
$sql "";
        
$where "";
        foreach(
$words as $key => $value)
        {
            if (
$where != ""
                
$where .= " OR ";
            
$where .= "($field LIKE '%$value%') ";
        }
        
$sql .= " SELECT $indexField$titleField, MATCH $field AGAINST ('$text') AS relev FROM $tableName WHERE {$where} ";
        
$sql .= " ORDER by relev DESC";
        if (
$simple)
        {
            
$sql "SELECT $indexField$titleField FROM $tableName";
        }
    
$res mysql_query($sql);    
    while (
$row = @mysql_fetch_assoc($res))
        
$rows [] = $row;
    }
    return 
$rows;
}
function 
addzero($value$charCount)
{
    
$v $value;
    for (
$i strlen($value); $i $charCount$i++)
    {
        
$v "0".$v;
    }    
    return 
$v;
}

class 
CPageNavigator

   var 
$CurrentPage;
   var 
$RowsInPage;
   var 
$CountOfRows;
   function 
CPageNavigator($countOfRows$curpage 1$rowsInPage 10)
   {
      
$this->CurrentPage $curpage;
    
$this->RowsInPage $rowsInPage;
    
$this->CountOfRows $countOfRows;
   }
   function 
GetLimitStatement()
   {
      
$st = ($this->CurrentPage 1)*$this->RowsInPage 1;
      return 
"LIMIT ".$st.",".$this->RowsInPage;
   } 
   function 
GetCountOfPages()
   {
      return @
ceil($this->CountOfRows $this->RowsInPage);
   }
   function 
TestNumberOfPage($page)
   {
      if (
$page <= 0)
      return 
false;
    if (
$page $this->GetCountOfPages())
      return 
false;
    return 
true;
   }
   function 
GetNavigator($addressPreffix)
   {
     
$increment 8;
     
$rows = array();
   if (
$this->CurrentPage $increment 1)
   {
      
$row['title'] = "&laquo;";
    
$row['page'] = 1;
    
$row['link'] = $addressPreffix."&pageNum=1";
    
array_push($rows$row);
   }
   for (
$i = -$increment$i <= $increment$i++)
     if (
$this->TestNumberOfPage($this->CurrentPage $i))
   {
      
$row['title'] = $this->CurrentPage $i;
    
$row['page'] = $this->CurrentPage $i;
    
$row['link'] = $addressPreffix."&pageNum=".$row['page'];
    
array_push($rows$row);
   }
   if (
$this->CurrentPage $increment $this->GetCountOfPages())
   {
      
$row['title'] = "&raquo;";
    
$row['page'] = $this->GetCountOfPages();
    
$row['link'] = $addressPreffix."&pageNum=".$row['page'];
    
array_push($rows$row);
   }
    foreach(
$rows as $key => $value)
    {
       
$title $value['title'];
     if (
$value['page'] == $this->CurrentPage)
       
$title "<b><u>".$title."</u></b>";
     
$link $value['link'];   
       
$str .= "<a href=\"{$link}\">{$title}</a>";
    }
   return 
$str;
   }
}
function 
GetParam($paramName)
{
    
$res mysql_query("SELECT * FROM AMCMS_params WHERE param_name = '{$paramName}'");
    
$arr mysql_fetch_array($res);
    return 
$arr['param_value'];    
}
function 
SetParam($paramName$paramValue)
{
    
$res mysql_query("SELECT * FROM AMCMS_params WHERE param_name = '{$paramName}'");
    
$arr mysql_fetch_array($res);
    if (
$arr == null)
        
$res mysql_query("INSERT INTO AMCMS_params (param_value, param_name) VALUES ('{$paramValue}', '{$paramName}')");    
    else
        
$res mysql_query("UPDATE AMCMS_params SET param_value = '{$paramValue}' WHERE param_name = '{$paramName}'");    
}
function 
ClearStringForTitle($title)
{
     
$str_win iconv("utf-8","cp1251"$title);
     
$str_win trim($str_win);                                         
     
$str_win str_replace("\n"" "$str_win);
     
$str_win str_replace("\r"" "$str_win);
     
$str_win ereg_replace(" +"" ",$str_win); 
     return 
iconv("cp1251","utf-8"$str_win);    
}
function 
GeoIpDetect($ip)
{
    
$pattern "/^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$/"
    
preg_match($pattern$ip$matches); 
    
$ipnum 16777216*$matches[1] + 65536*$matches[2] + 256*$matches[3] + $matches[4];
    
print_r($matches);    
    echo 
$ipnum;
    
$sql "SELECT * FROM AMCMS_geoip WHERE $ipnum >= begin_num AND $ipnum <= end_num LIMIT 1";
    echo 
$sql;
    
$res mysql_query($sql);
    
$row mysql_fetch_array($res);
    
print_r($row);
    
$res->city $city;
    
$res->country $country;
    return 
$res;
}

function 
GetYearSelectForm($name$method "get"$selectedYear ""$startYear "")
{
        if (
$startYear == "")
            
$startYear GetParam("StartYear");    
        global 
$ALANG;
        if (
$selectedYear == "")
            
$selectedYear GetCurrentYear();
        
$option1 "";
        for(
$i GetCurrentYear() + 1$i >= $startYear$i--)
        {
             
$selected "";
             if (
$i == $selectedYear)
                
$selected "selected=\"selected\"";
             
$option1 .= "<option {$selected} value=\"{$i}\">".$i." ".$ALANG['year']."</option>";
        }
        
$select1 "<select name=\"{$name}\" id=\"{$name}\" onchange=\"submit1.click();\">{$option1}</select> ";
        
$input "<input style=\"display:none;\" type=\"submit\" name=\"submit1\" id=\"submit1\" value=\"".$ALANG['Select'] ."\" />";
        
$selectorHtml "<div style=\"text-align:center\"><form style=\"margin-bottom:20px\" name=\"datefrm\" method=\"{$method}\"> ".$ALANG['Select'].": {$select1} {$select2} {$input}</form></div>";
        return     
$selectorHtml;        

}
?>

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by PinoyWH1Z | C99Shell Github | Generation time: 0.0176 ]--