Ejemplo n.º 1
0
/**
 * Prints a download link for a file, depending on the plugin options including the downloadcount and filesize
 * @param string $file the path to a file to print a download link.
 * @param string $linktext Optionally how you wish to call the link. Set/leave  to NULL to use the filename.
 */
function printDownloadURL($file, $linktext = NULL)
{
    if (substr($file, 0, 1) != '/' && strpos($file, ':') === false) {
        $file = SERVERPATH . '/' . getOption('downloadList_directory') . '/' . $file;
    }
    $filesize = '';
    if (getOption('downloadList_showfilesize')) {
        $filesize = @filesize(internalToFilesystem($file));
        $filesize = ' (' . byteConvert($filesize) . ')';
    }
    if (getOption('downloadList_showdownloadcounter')) {
        $downloaditem = DownloadList::getListItemFromDB($file);
        if ($downloaditem) {
            $downloadcount = ' - ' . sprintf(ngettext('%u download', '%u downloads', $downloaditem['data']), $downloaditem['data']);
        } else {
            $downloadcount = ' - ' . gettext('0 downloads');
        }
        $filesize .= $downloadcount;
    }
    if (empty($linktext)) {
        $filename = basename($file);
    } else {
        $filename = $linktext;
    }
    echo '<a href="' . html_encode(getDownloadURL($file)) . '" rel="nofollow" class="downloadlist_link">' . html_encode($filename) . '</a><small>' . $filesize . '</small>';
}
Ejemplo n.º 2
0
function getDownloadLink($ext)
{
    return '<a href="' . getDownloadURL($ext) . '">' . "Click to download the .{$ext} file</a>";
}
Ejemplo n.º 3
0
         $sql = \Lobby\DB::getDBH()->query("SELECT `value` FROM `lobby` WHERE `key_name` = 'downloads'");
         $lobby_data = json_decode($sql->fetchColumn(), true);
         $statVersion = $version;
         if ($version === "windows" || $version === "linux") {
             $statVersion = $version . "-{$this->lobby_version}";
         }
         if (!is_array($lobby_data)) {
             $lobby_data = array($statVersion => 0);
         }
         $lobby_data[$statVersion] = isset($lobby_data[$statVersion]) ? $lobby_data[$statVersion] + 1 : 1;
         $sql = \Lobby\DB::getDBH()->prepare("UPDATE `lobby` SET `value` = ? WHERE `key_name` = 'downloads'");
         $sql->execute(array(json_encode($lobby_data)));
         /**
          * Download
          */
         header("Location: " . getDownloadURL($version, $lobby_downloads));
     }
 } else {
     if ($what === "updates") {
         /**
          * Don't mess with the response
          */
         $response = array("version" => $this->lobby_version, "released" => $this->lobby_released, "release_notes" => $this->lobby_release_notes, "notify" => array("items" => array("site-compressor" => array("contents" => "Compress your sites with the new Site Compressor!", "href" => "/admin/lobby-store.php?app=site-compressor")), "remove_items" => array("amoebam")));
         if (isset($_POST['apps'])) {
             $apps = $_POST['apps'];
             if (preg_match("/\\,/", $apps)) {
                 $apps = explode(",", $apps);
             } else {
                 /**
                  * Only a single app is present
                  */
Ejemplo n.º 4
0
/**
 * @deprecated
 * @since 1.4.6
 */
function getDownloadLink($file)
{
    deprecated_functions::notify(gettext('use getDownloadURL()'));
    return getDownloadURL($file, $linktext);
}