Вход Регистрация
Файл: vsime.com/system/functions/dir_files_access.php
Строк: 31
<?
    
function dir_files_access ($dir$text=NULL$prov=0)
    {
        global 
$moderate_files$user$dbi;
        
$dir['counter_array'] = explode('/'$dir['counter']);
        
$ank profile($dir['id_user']);
        foreach (
$dir['counter_array'] AS $key => $dir_oth_id)
        {
            
$ok 1;
            if (
$dir_oth_id != && mysqli_result("SELECT COUNT(*) FROM `files` WHERE `id` = '$dir_oth_id' AND `type` = 'dir'")!=0)
            {
                
$dir_oth mysqli_fetch_array(mysqli_query($dbi"SELECT * FROM `files` WHERE `id` = '$dir_oth_id' AND `type` = 'dir'"));
                
$dir_oth['dir_img'] = dir_img($dir_oth['access']);
            }
            else
            {
                
$dir_oth = array();
                
$dir_oth['id'] = 0;
                
$dir_oth['name'] = "Файлы";
                
$dir_oth['counter'] = '/0/';
                
$dir_oth['access'] = 'all';
                
$dir_oth['dir_img'] = dir_img($dir_oth['access']);
            }
            if(isset(
$_POST['password_dir']) && $dir_oth['access'] == 'pass')
            {
                
setcookie("password_files_".$_SERVER['HTTP_HOST']."_$dir_oth[id]",$_POST['password_dir']);
                if(isset(
$_POST['password_dir']) && $_POST['password_dir'] == $dir['password'])header("Location: ?dir=$dir_oth[id]&enter=ok");
            }
            if (
$dir_oth['access']=='only_me')
            {
                if(
$ank['id'] == $user['id'] && isset($user) || isset($moderate_files))
                {
                    
$ok 1;
                } else {
                    if (
$text == NULL)
                    {
                        
$ok 0;
                        if (
$prov == 1)break;
                        if (
$prov == 0)
                        {
                            
show_errors("Папка $dir_oth[dir_img] <b>".hsc($dir_oth['name'])."</b> доступна только автору.");
                            
ex_foot();
                        }
                    } else
                    {
                        
$ok 0;
                        if (
$prov == 1)break;
                        if (
$prov == 0)
                        {
                            echo 
$text;
                            exit();
                        }
                    }
                }
            } elseif (
$dir_oth['access'] == 'friends') {
                if(
$ank['id'] == $user['id'] && isset($user) || isset($moderate_files) || is_friend($ank['id'], $user['id']))
                {
                    
$ok 1;
                } else {
                    if (
$text == NULL)
                    {
                        
$ok 0;
                        if (
$prov == 1)break;
                        if (
$prov == 0)
                        {
                            
show_errors("Папка $dir_oth[dir_img] <b>".hsc($dir_oth['name'])."</b> доступна только друзьям автора.");
                            
ex_foot();
                        }
                    } else
                    {
                        
$ok 0;
                        if (
$prov == 1)break;
                        if (
$prov == 0)
                        {
                            echo 
$text;
                            exit();
                        }
                    }
                }
            } elseif (
$dir_oth['access'] == 'pass') {
                if (isset(
$_COOKIE["password_files_".$_SERVER['HTTP_HOST']."_$dir_oth[id]"]) && $_COOKIE["password_files_".$_SERVER['HTTP_HOST']."_$dir_oth[id]"] == $dir_oth['password'] || $ank['id'] == $user['id'] && isset($user) || isset($moderate_files))
                {
                    
$ok 1;
                } else {
                    if (
$text == NULL)
                    {
                        
$ok 0;
                        if (
$prov == 1)break;
                        if (
$prov == 0)
                        {
                            if(isset(
$_POST['password_dir']) && $_POST['password_dir'] != $dir_oth['password'])show_errors("Неправильный пароль.");
                            echo 
"<form method='post'>n";
                                echo 
"Папка $dir_oth[dir_img] <b>".hsc($dir_oth['name'])."</b> доступна только по паролю.<br />Введите пароль:<br />n";
                                echo 
"<input type='text' name='password_dir' value=''><br />n";
                                echo 
"<input type='submit' name='Далее'>n";
                            echo 
"</form>";
                            
ex_foot();
                        }
                    } else {
                        
$ok 0;
                        if (
$prov == 1)break;
                        if (
$prov == 0)
                        {
                            echo 
$text;
                            exit();
                        }
                    }
                }
            } elseif (
$dir_oth['access'] == 'auth') {
                if(isset(
$user))
                {
                    
$ok 1;
                } else {
                    if (
$text == NULL)
                    {
                        
$ok 0;
                        if (
$prov == 1)break;
                        if (
$prov == 0)
                        {
                            
show_errors("Папка $dir_oth[dir_img] <b>".hsc($dir_oth['name'])."</b> доступна только авторизированным пользователям.");
                            
ex_foot();
                        }
                    } else {
                        
$ok 0;
                        if (
$prov == 1)break;
                        if (
$prov == 0)
                        {
                            echo 
$text;
                            exit();
                        }
                    }
                }
            }
        }
        if (
$prov == 1)return $ok;
    }
?>
Онлайн: 1
Реклама