Esempio n. 1
0
 public static function CreateForActualLink($link)
 {
     $ob = new self();
     $ob->SetAuthorID(GetUserID());
     $ob->SetActualLink($link);
     $random_link = SecretLink::GenerateRandomLink();
     do {
         $old = SecretLink::FetchBy(['select_list' => 'id', 'eq_conds' => ['public_link' => $random_link]]);
         if (count($old) != 0) {
             $random_link = SecretLink::GenerateRandomLink();
         } else {
             break;
         }
     } while (1);
     $ob->SetPublicLink($random_link);
     $res = SecretLink::InsertToDB($ob);
     if (Error::IsError($res)) {
         return $res;
     }
     return $ob;
 }
Esempio n. 2
0
<?php

require_once 'utility_lgmis_lib.php';
include_once $link_to_utility_authorization;
if (isset($_GET['public_link'])) {
    SecretLink::ClearOldLinks();
    $link = SecretLink::FetchBy(['select_list' => 'actual_link', 'eq_conds' => ['public_link' => $_GET['public_link']], 'is_unique' => true]);
    if (Error::IsError($link)) {
        echo 'Ссылка не найдена';
        exit;
    }
    global $link_prefix;
    header('Location: ' . $link_prefix . $link->GetActualLink());
    exit;
}
$file_path = $_SERVER['DOCUMENT_ROOT'] . $link_prefix;
if (isset($_GET['file_path'])) {
    $file_path .= $_GET['file_path'];
} else {
    if (isset($_POST['file_path'])) {
        $file_path .= $_POST['file_path'];
    } else {
        echo 'exit';
        exit;
    }
}
if (file_exists($file_path)) {
    if (!is_dir($file_path)) {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="' . urldecode(basename($file_path)) . '"');