• midi_karl

    (@midi_karl)


    If the webroot directory is in some kind of subdirectory of a host, the download media button seems not to work properly.
    After migration to a professional provider the problem occured.
    If i copy the file Url e.g.:

    https://karl-westermann.org/wordpress/wp-content/uploads/2013/01/Notturno.mp3

    directly to the adress bar of the browser, the file gets played.

    when hitting the download button i get the error:
    “The file /…./pages/6c/75/d…..5/home/htdocs/wordpress/wp-content/uploads/2013/01/Notturno.mp3 doesn’t exist; check the URL”

    the part “/…/pages/6c/75/d…..5/home/htdocs” is some kind of hoster specific directory tree i have no influence on.

    Without being a php programmer i had a look in the map_download.php and there you generate the string path for the download files with diffrent variables.
    Maybe “$web_root = $_SERVER[“DOCUMENT_ROOT”]” produces wrong results in the new setup.

    Did you try such a setup?
    Any suggestions?

    Sincerly

    https://www.ads-software.com/plugins/wp-miniaudioplayer/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author pupunzi

    (@pupunzi)

    Hi,
    I made a test page with your audio file and it’s working fine for me:
    https://pupunzi.open-lab.com/audio-test/

    You should check with your web-master why you cant reach the correct path to the file.

    Bye,
    Matteo

    Thread Starter midi_karl

    (@midi_karl)

    Hi Matteo,

    My web-master told me that the problem arises, if the home directory of the domain is not the same as the root directory of the wordpress installation.
    In my case the domain karl-westermann.org has the home directory ‘/karl_westermann’ and within this the root directory of the wordpress installation is ‘/karl_westermann/wordpress’.

    As a workaround my webmaster modified the plug-in coding of ‘map_downloads.php’ as follows:

    <?php
    /**
    * Download file.
    */

    $wpHomeDir = ‘/karl_westermann’;

    /* Check if there is the cookie that allow the download */

    if(!isset($_COOKIE[“mapdownload”]) || $_COOKIE[“mapdownload”] !== “true”)
    die ($_COOKIE[“mapdownload”].’ <b>Something goes wrong, you don\’t have permission to use this page, sorry.</b>’) ;

    unset($_COOKIE[‘mapdownload’]);
    setcookie(‘mapdownload’, ‘false’, time() – 3600, ‘/’);

    $file_name = $_GET[“filename”];
    $file_url = $_GET[“fileurl”];
    $file_url = str_replace(” “, “%20”, $file_url);

    $web_root = $_SERVER[“DOCUMENT_ROOT”];
    $web_address = $_SERVER[‘HTTP_HOST’];

    $pos = strrpos($file_url, $web_address);

    if($pos){

    if (isset($_SERVER[‘HTTPS’]) &&
    ($_SERVER[‘HTTPS’] == ‘on’ || $_SERVER[‘HTTPS’] == 1) ||
    isset($_SERVER[‘HTTP_X_FORWARDED_PROTO’]) &&
    $_SERVER[‘HTTP_X_FORWARDED_PROTO’] == ‘https’) {
    $protocol = ‘https://&#8217;;
    }
    else {
    $protocol = ‘https://&#8217;;
    }

    $file_url = str_replace ($protocol. $web_address .’/’, ”, $file_url);
    $file_url = $web_root . $wpHomeDir .”/”. $file_url;
    $file_url = str_replace(‘//’, ‘/’, $file_url);

    //die($protocol . ” — ” .$web_root . ” — ” .$web_address . ” — ” . $file_url );

    }

    Thread Starter midi_karl

    (@midi_karl)

    Hello Matteo,

    Modifying the coding as a work-around is incommodious when updating the plug-in and not good practise.
    As it is good and common hosting practise to separate program files from data files, I suggest you to offer the above modification or an equivalent solution in the settings of your plug-in.

    Regards
    Karl

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Download od media not working if wordpress not in webroot directory’ is closed to new replies.