Файл: vsime.com/system/functions/dir_fotos_access.php
Строк: 31
<?
    function dir_fotos_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 != 0 && mysqli_result("SELECT COUNT(*) FROM `foto` WHERE `id` = '$dir_oth_id' AND `type` = 'dir'")!=0)
            {
                $dir_oth = mysqli_fetch_array(mysqli_query($dbi, "SELECT * FROM `foto` 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_fotos_".$_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_file))
                {
                    $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_file) || 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_fotos_".$_SERVER['HTTP_HOST']."_$dir_oth[id]"]) && $_COOKIE["password_fotos_".$_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;
    }
?>