0) {
$uptimeString .= $days;
$uptimeString .= (($days == 1) ? " day" : " days");
}
if ($hours > 0) {
$uptimeString .= (($days > 0) ? ", " : "") . $hours;
$uptimeString .= (($hours == 1) ? " hour" : " hours");
}
if ($mins > 0) {
$uptimeString .= (($days > 0 || $hours > 0) ? ", " : "") . $mins;
$uptimeString .= (($mins == 1) ? " minute" : " minutes");
}
if ($secs > 0) {
$uptimeString .= (($days > 0 || $hours > 0 || $mins > 0) ? ", " : "") . $secs;
$uptimeString .= (($secs == 1) ? " second" : " seconds");
}
return $uptimeString;
}
function dirsize($directory) {
if( ! is_dir( $directory ) ) return - 1;
$size = 0;
if( $DIR = opendir( $directory ) ) {
while ( ($dirfile = readdir( $DIR )) !== false ) {
if( @is_link( $directory . '/' . $dirfile ) || $dirfile == '.' || $dirfile == '..' ) continue;
if( @is_file( $directory . '/' . $dirfile ) ) $size += filesize( $directory . '/' . $dirfile );
else if( @is_dir( $directory . '/' . $dirfile ) ) {
$dirSize = dirsize( $directory . '/' . $dirfile );
if( $dirSize >= 0 ) $size += $dirSize;
else return - 1;
}
}
closedir( $DIR );
}
return $size;
}
function check_login($username, $md5_password, $post = true) {
global $member_id, $db, $user_group, $lang, $_IP, $_TIME, $config;
if( $username == "" OR $md5_password == "" ) return false;
$result = false;
if( $post ) {
$username = $db->safesql( $username );
$md5_password = md5( $md5_password );
if ( preg_match( "/[\||\'|\<|\>|\"|\!|\?|\$|\@|\/|\\\|\&\~\*\+]/", $username) ) return false; $where_name = "name='{$username}'";
$member_id = $db->super_query( "SELECT * FROM " . USERPREFIX . "_users WHERE {$where_name} AND password='{$md5_password}'" );
if( $member_id['user_id'] and $user_group[$member_id['user_group']]['allow_admin'] and $member_id['banned'] != 'yes' ) $result = TRUE;
else $member_id = array ();
} else {
$username = intval( $username );
$md5_password = md5( $md5_password );
$member_id = $db->super_query( "SELECT * FROM " . USERPREFIX . "_users WHERE user_id='$username'" );
if( $member_id['user_id'] AND $member_id['password'] AND $member_id['password'] == $md5_password AND $user_group[$member_id['user_group']]['allow_admin'] AND $member_id['banned'] != 'yes' ) $result = TRUE;
else $member_id = array ();
}
if( $result ) {
if( !allowed_ip( $row['allowed_ip'] ) ) {
$member_id = array ();
$result = false;
set_cookie( "dle_user_id", "", 0 );
set_cookie( "dle_name", "", 0 );
set_cookie( "dle_password", "", 0 );
set_cookie( "dle_hash", "", 0 );
@session_destroy();
@session_unset();
set_cookie( session_name(), "", 0 );
msg( "info", $lang['index_msge'], $lang['ip_block'] );
}
}
return $result;
}
function mksize($bytes) {
if ($bytes < 1000)
return $bytes. " b";
if ($bytes < 1000 * 1024)
return number_format($bytes / 1024, 2) . " Kb";
if ($bytes < 1000 * 1048576)
return number_format($bytes / 1048576, 2) . " Mb";
if ($bytes < 1000 * 1073741824)
return number_format($bytes / 1073741824, 2) . " Gb";
if ($bytes < 1000 * 1099511627776)
return number_format($bytes / 1099511627776, 2) . " Tb";
if ($bytes < 1000 * 1125899906842620)
return number_format($bytes / 1125899906842620, 2) . " Pb";
if ($bytes < 1000 * 1152921504606850000)
return number_format($bytes / 1152921504606850000, 2) . " Eb";
}
function CheckCanGzip() {
if( headers_sent() || connection_aborted() || ! function_exists( 'ob_gzhandler' ) || ini_get( 'zlib.output_compression' ) ) return 0;
if( strpos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip' ) !== false ) return "x-gzip";
if( strpos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) !== false ) return "gzip";
return 0;
}
function GzipOut() {
global $Timer, $db;
$ENCODING = CheckCanGzip();
if( $ENCODING ) {
$Contents = ob_get_contents();
ob_end_clean();
header( "Content-Encoding: $ENCODING" );
$Contents = gzencode( $Contents, 1, FORCE_GZIP );
echo $Contents;
exit();
} else {
// ob_end_flush();
exit();
}
}
class microTimer {
function start() {
global $starttime;
$mtime = microtime();
$mtime = explode( ' ', $mtime );
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
}
function stop() {
global $starttime;
$mtime = microtime();
$mtime = explode( ' ', $mtime );
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = round( ($endtime - $starttime), 5 );
return $totaltime;
}
}
function allowed_ip($ip_array) {
$ip_array = trim( $ip_array );
if( $ip_array == "" ) {
return true;
}
$ip_array = explode( "|", $ip_array );
$db_ip_split = explode( ".", $_SERVER['REMOTE_ADDR'] );
foreach ( $ip_array as $ip ) {
$ip_check_matches = 0;
$this_ip_split = explode( ".", trim( $ip ) );
for($i_i = 0; $i_i < 4; $i_i ++) {
if( $this_ip_split[$i_i] == $db_ip_split[$i_i] or $this_ip_split[$i_i] == '*' ) {
$ip_check_matches += 1;
}
}
if( $ip_check_matches == 4 ) return true;
}
return FALSE;
}
////////////////////////////////////////////////////////
// Function: msg
// Description: Displays message to user
function msg($type, $title, $text, $back = FALSE) {
global $lang;
if( $back ) {
$back = "
$lang[func_msg]";
}
echoheader( $type, $title );
echo <<
HTML;
echofooter();
exit();
}
function echoheader($image, $header_text) {
global $PHP_SELF, $skin_header, $member_id, $user_group;
$skin_header = str_replace( "{header-text}", $header_text, $skin_header );
$skin_header = str_replace( "{user}", $member_id['name'], $skin_header );
$skin_header = str_replace( "{group}", $user_group[$member_id['user_group']]['group_name'], $skin_header );
echo $skin_header;
}
function echofooter() {
global $PHP_SELF, $is_loged_in, $skin_footer;
echo $skin_footer;
}
function listdir($dir) {
$current_dir = opendir( $dir );
while ( $entryname = readdir( $current_dir ) ) {
if( is_dir( "$dir/$entryname" ) and ($entryname != "." and $entryname != "..") ) {
listdir( "${dir}/${entryname}" );
} elseif( $entryname != "." and $entryname != ".." ) {
unlink( "${dir}/${entryname}" );
}
}
@closedir( $current_dir );
rmdir( ${dir} );
}
function totranslit( $var, $lower = true, $punkt = true ) {
global $langtranslit;
if ( is_array($var) ) return "";
if (!is_array ( $langtranslit ) OR !count( $langtranslit ) ) {
$langtranslit = array('à' => 'a', 'á' => 'b', 'â' => 'v', 'ã' => 'g', 'ä' => 'd', 'å' => 'e', '¸' => 'e', 'æ' => 'zh', 'ç' => 'z', 'è' => 'i', 'é' => 'y', 'ê' => 'k', 'ë' => 'l', 'ì' => 'm', 'í' => 'n', 'î' => 'o', 'ï' => 'p', 'ð' => 'r', 'ñ' => 's', 'ò' => 't', 'ó' => 'u', 'ô' => 'f', 'õ' => 'h', 'ö' => 'c', '÷' => 'ch', 'ø' => 'sh', 'ù' => 'sch', 'ü' => '', 'û' => 'y', 'ú' => '', 'ý' => 'e', 'þ' => 'yu', 'ÿ' => 'ya', "¿" => "yi", "º" => "ye",
'À' => 'A', 'Á' => 'B', 'Â' => 'V', 'Ã' => 'G', 'Ä' => 'D', 'Å' => 'E', '¨' => 'E', 'Æ' => 'Zh', 'Ç' => 'Z', 'È' => 'I', 'É' => 'Y', 'Ê' => 'K', 'Ë' => 'L', 'Ì' => 'M', 'Í' => 'N', 'Î' => 'O', 'Ï' => 'P', 'Ð' => 'R', 'Ñ' => 'S', 'Ò' => 'T', 'Ó' => 'U', 'Ô' => 'F', 'Õ' => 'H', 'Ö' => 'C', '×' => 'Ch', 'Ø' => 'Sh', 'Ù' => 'Sch', 'Ü' => '', 'Û' => 'Y', 'Ú' => '', 'Ý' => 'E', 'Þ' => 'Yu', 'ß' => 'Ya', "¯" => "yi", "ª" => "ye",);
}
$var = trim( strip_tags( $var ) );
$var = preg_replace( "/\s+/ms", "-", $var );
$var = str_replace( "/", "-", $var );
$var = strtr($var, $langtranslit);
if( $punkt ) {$var = preg_replace( "/[^a-z0-9\_\-.]+/mi", "", $var );}else{$var = preg_replace( "/[^a-z0-9\_\-]+/mi", "", $var );}
$var = preg_replace( '#[\-]+#i', '-', $var );
if( $lower ) {$var = strtolower( $var );}
$var = str_ireplace( ".php", "", $var );
$var = str_ireplace( ".php", ".ppp", $var );
if( strlen( $var ) > 50 ) {
$var = substr( $var, 0, 50 );
if( ($temp_max = strrpos( $var, '-' )) ) $var = substr( $var, 0, $temp_max );
}
return $var;
}
// ********************************************************************************
// Show Radio
// ********************************************************************************
function showRadio($title = "", $description = "", $allow_name = "", $row = false){
global $f_lg;
if ($row[$allow_name])
{
$o_value = "checked";
$t_value = "";
}
else
{
$o_value = "";
$t_value = "checked";
}
echo"
{$title} {$description}
|
{$f_lg['yes']}
{$f_lg['no']}
|
|
";
}
// ********************************************************************************
// showRow
// ********************************************************************************
function showRow($title="", $description="", $field="")
{
echo"
$title $description
| $field
|
|
";
$bg = ""; $i++;
}
// ********************************************************************************
// makeDropDown
// ********************************************************************************
function makeDropDown($options, $name, $selected)
{
$output = "