Просмотр файла sman/includs/configurations.php

Размер файла: 2.51Kb
<?php

session_start(); //включаем работу сессии

define("ROOT", $_SERVER["DOCUMENT_ROOT"]); //корень

//error_reporting(0); //подавляем вывод ошибок


$min_str = 0; //с какой строки начинать

$max_str = 40; //максимальное количество строк на странице

$max_str_page = 40; //максимальное количество строк на странице для пагинатора

$ras = array('php', 'zip', 'txt', 'html', 'css', 'jpg', 'jpeg', 'gif', 'png'); //массив форматов для определения иконок

if (isset($_GET['page']) && is_numeric($_GET['page'])) {

$min_str = ($_GET['page']*$max_str);

$max_str = ($_GET['page']*$max_str)+$max_str;

}


if (!isset($_COOKIE['login']) && !isset($_COOKIE['password']) && $_SERVER['PHP_SELF'] !== '/sman/enter.php') {

header("Location: /sman/enter.php");

exit;

} else if (isset($_COOKIE['login']) && isset($_COOKIE['password']) && $_SERVER['PHP_SELF'] !== '/sman/index.php') {



}






function dir_sizes($root, $path=NULL) {

if (empty($size_dir))

$size_dir = 0;


$dir = scandir($root.$path);


foreach ($dir as $key => $value) {

if ($value != '.' && $value != '..' && $value != NULL) {

if (is_file($root.$path.'/'.$value)) {

$size_dir += filesize($root.$path.'/'.$value);

}

if (is_dir($root.$path.'/'.$value)) {
$size_dir += dir_sizes($root, $path.'/'.$value);


}
}
}

return $size_dir;

}







function size_object($file, $dir=NULL) {


if ($dir == false)

$size = filesize($file);
  
else 

$size = $file;

if ($size == NULL) 

$size = 0;

  $show = ' б.';


  if ($size < 1024 && $size != NULL) {

  $size = round($size/1024, 2);
 
 $show = ' кб.';
}

  if ($size >= 1024) {
 
  $size = round($size/1024, 2);
  
  $show = ' кб.';
  
  }
  
  if ($size >= 1024) {
 
  $size = round($size/1024, 2);
  
  $show = ' мб.';
  
  }

  if ($size >= 1024) {
 
  $size = round($size/1024, 2);
  
  $show = ' гиг.';
}


 return $size.$show;

}


function format($file) {

$format = end(explode('.', $file));

return $format;

}

function icon($icon) {

global $ras;

if (is_dir($icon)) {

$icon = '<img src = "/sman/style/icons/path.png"> ';

clearstatcache();

} else {

if (in_array(format($icon), $ras))

$icon = '<img src = "/sman/style/icons/'.format($icon).'.png"> ';

else if (!in_array(format($icon), $ras))

$icon = '<img src = "/sman/style/icons/file.png"> ';

}

return $icon;

}

?>