<?php
$rew=date_default_timezone_set("Asia/Krasnoyarsk");
function uw($vv,$p)
{if ($p) {return iconv("utf-8","Windows-1251",$vv);} else {return $vv;}} // 
//--------------
function wu($vv,$p)
{
//if ($p) {return iconv("Windows-1251","utf-8",$vv);} else {return $vv;}
return $vv;
} // 
//---------------
function full_del_dir ($directory)    // 
{$dir = opendir($directory);
  while (($file = readdir($dir)) !== false)
//  while(($file = readdir($dir)))
  {if ( is_file ($directory."/".$file))
   {unlink ($directory."/".$file);}
   else if ( is_dir ($directory."/".$file) && ($file != ".") && ($file != ".."))
    {full_del_dir ($directory."/".$file);}
  }
  closedir ($dir);
  rmdir ($directory);
  }
// -----------------
function c($vv,$p)
{
//
//
$y='qwertyuiopasdfghjklzxcvbnmMNBVCX3LKJHGFD7APOIUYTREWQ12Z456S890_/';
$d='qazwsx7dcrfvtg()yhnujmiklopQWERTYUIOPASDFGHJKLZXCVBNM639102584eb';


if ($p==1) 
{return strrev(strtr($vv, $y, $d));}
else
{return strrev(strtr($vv, $d, $y));}
}  

function ktex($p)       // 
{
$mk=str_split ( $p);  // 
$ks=' (),_-1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';               // 
for ($i=0; $i < count($mk); $i++)      //
{
$p1=$mk[$i];             // 
if ($p1<>" ")            // 
{ 
if (strpos($ks,$p1)==0) // 
{
return $mk[$i];
}
} 
}
return "";
}



function tr($p)
{
return $p;
}


function rtr($p)
{
return $p;
}


// copy a directory and all subdirectories and files (recursive)
 // void dircpy( str 'source directory', str 'destination directory' [, bool 'overwrite existing files'] )
function dircpy($basePath, $source, $dest, $overwrite = false){
    if(!is_dir($basePath . $dest)) //Lets just make sure our new folder is already created. Alright so its not efficient to check each time... bite me
    mkdir($basePath . $dest);
    if($handle = opendir($basePath . $source)){        // if the folder exploration is sucsessful, continue
        while(false !== ($file = readdir($handle))){ // as long as storing the next file to $file is successful, continue
            if($file != '.' && $file != '..'){
                $path = $source . '/' . $file;
                if(is_file($basePath . $path)){
                    if(!is_file($basePath . $dest . '/' . $file) || $overwrite)
                    if(!@copy($basePath . $path, $basePath . $dest . '/' . $file)){
                        echo '<font color="red">File ('.$path.') could not be copied, likely a permissions problem.</font>';
                    }
                } elseif(is_dir($basePath . $path)){
                    if(!is_dir($basePath . $dest . '/' . $file))
                    mkdir($basePath . $dest . '/' . $file); // make subdirectory before subdirectory is copied
                    dircpy($basePath, $path, $dest . '/' . $file, $overwrite); //recurse!
                }
            }
        }
        closedir($handle);
    }
}








?>