Simple Invoices logo
    • CommentAuthoryusufm
    • CommentTimeMar 14th 2008 edited
     permalink
    Hi

    Firstly, the system looks wonderful, and it seems like it will satisfy everything I need.

    But, my PDF's are not being automatically generated. The good news is that I know why. Where I need help is in a permanent fix for this.

    When I click the PDF icon to get my PDF invoice, it reloads but moans:

    Cannot connect to invoices.lan\:80 - (12637320)

    Connection error

    Could not open URL http://invoices.lan\/index.php?module=invoices&view=templates/template&invoice=9&action=view&location=pdf you've specified.

    No response from server

    Fetching: http://invoices.lan\/index.php?module=invoices&view=templates/template&invoice=9&action=view&location=pdf Cannot connect to invoices.lan\:80 - (12637320) Cannot open [url=http://invoices.lan\/index.php?module=invoices&view=templates/template&invoice=9&action=view&location=pdf
    ]http://invoices.lan\/index.php?module=invoices&view=templates/template&invoice=9&action=view&location=pdf

    The problem is the odd backslash after invoices.lan.

    When I change the URL from

    http://invoices.lan/library/pdf/html2ps.php?&process_mode=single&renderfields=1&renderlinks=1&renderimages=1&scalepoints=1&pixels=800&media=A4&leftmargin=15&rightmargin=15&topmargin=15&bottommargin=15&transparency_workaround=1&imagequality_workaround=1&output=1&location=pdf&pdfname=Invoice9&URL=http%3A%2F%2Finvoices.lan%5C%2Findex.php%3Fmodule%3Dinvoices%26view%3Dtemplates%2Ftemplate%26invoice%3D9%26action%3Dview%26location%3Dpdf

    to

    http://invoices.lan/library/pdf/html2ps.php?&process_mode=single&renderfields=1&renderlinks=1&renderimages=1&scalepoints=1&pixels=800&media=A4&leftmargin=15&rightmargin=15&topmargin=15&bottommargin=15&transparency_workaround=1&imagequality_workaround=1&output=1&location=pdf&pdfname=Invoice9&URL=http%3A%2F%2Finvoices.lan%2Findex.php%3Fmodule%3Dinvoices%26view%3Dtemplates%2Ftemplate%26invoice%3D9%26action%3Dview%26location%3Dpdf

    Look for invoices.lan in the URL - I removed the backslash (%5C) ... and then it works.

    I was hoping that you clever people could point me to the right place to make this a permanent fix?

    I'm using Vista Home Premium (no comments please :) ...), IIS7, MySQL, and PHP5 ...

    Also, I was getting many notices about undeclared variables, so I used the config.php line "error_reporting(E_ALL & ~E_NOTICE);" so those went away. But one persisted. Namely REQUEST_URI was not populated by IIS. Searching the net led me to this fix:


    // Work around REQUEST_URI bug under W2K/IIS/CGI/PHP
    if (!isset($_SERVER['REQUEST_URI']) and isset($_SERVER['SCRIPT_NAME'])) {
    $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
    if (isset($_SERVER['QUERY_STRING']) and !empty($_SERVER['QUERY_STRING']))
    $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];


    from https://bugzilla.wikimedia.org/show_bug.cgi?id=3000 (but the PDF problem existed before anyway... so this code didn't introduce the problem).

    Thanks for listening... I hope we have a fix for my configuration to help some other Microsoft user out there :)

    Regards
    Yusuf
    • CommentAuthoryusufm
    • CommentTimeMar 18th 2008 edited
     permalink
    Okay, I managed to fix it after reading the fix on this page for a similar problem: http://www.mihalism.com/index.php?showtopic=918

    I replaced the line "$this->url = $url;" in the fetch() function in ./library/pdf/fetcher.url.class.php with:

    $url = str_replace("\/", "/", $url);
    $this->url = $url;


    On a separate note, can someone explain why the new line works? To me (a Perl programmer) it seems that I am replacing all occurences of "/" (forward slash) with "/" ... the backslash should "escape" the "/" ... I'm so confused.

    But hey, it works!!! My PDF's generate without the need to edit the URL in the error page...

    BTW, it must be IIS, because IE7 and Firefox do the same thing.
    • CommentAuthorjustin
    • CommentTimeMar 19th 2008 edited
     permalink
    Hey Yusufm,

    thanks for finding the solution

    but wondering if you can try editing the way Simple Invoices gets the url

    refer: ./includes/sql_queries.php

    function urlPDF($invoiceID)
    {

    global $http_auth;

    $script = "/index.php?module=invoices&view=templates/template&invoice=$invoiceID&action=view&location=pdf";
    $port = "";
    $dir = dirname($_SERVER['PHP_SELF']);

    //set the port of http(s) section
    if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') {
    $_SERVER['FULL_URL'] = "https://";
    //http://simpleinvoices.org/forum/topic-457.html
    //below code no longer required - please test if your using a non standard port
    /*
    if($_SERVER['SERVER_PORT']!="443") {
    $port .= "://" . $_SERVER['SERVER_PORT'];
    }
    */
    } else {
    $_SERVER['FULL_URL'] = "http://";
    //http://simpleinvoices.org/forum/topic-457.html
    //below code no longer required - please test if your using a non standard port
    /*
    if($_SERVER['SERVER_PORT']!="80") {
    $port = ":" . $_SERVER['SERVER_PORT'];
    }
    */
    }

    //merge it all togehter
    if (isset($_SERVER['HTTP_HOST'])) {
    $_SERVER['FULL_URL'] .= $http_auth.$_SERVER['HTTP_HOST'].$dir.$script;
    } else {
    $_SERVER['FULL_URL'] .= $http_auth.$_SERVER['HTTP_HOST'].$dir.$script;
    }

    return $_SERVER['FULL_URL'];

    }


    and see if you can fix it that way

    as editing a 3rd party library that we depend on is not the best way - as when we go to update it - we might forget to reapply this fix

    Cheers

    Justin