Results 1 to 3 of 3

Thread: list.js Widget from atProxy Not Showing Up

  1. #1

    list.js Widget from atProxy Not Showing Up

    I have a block of JavaScript code that is designed to be embedded into any web page. It displays a list of items from a database. In the .js file is actually a lot of PHP code within JavaScript.

    The problem: The cut-n-paste widget does not actually show up. It's just blank. There is no error data in Apache or PHP, so I am stumped. This is happening on all 3 of my servers and in both IE and Firefox.

    Example: Website Blog Proxy List Widget

    Half way down the page it says 'The widget looks like this:', but as you can see no widget is actually displayed there where it's supossed to be.

    This is the JavaScript code designed to be embedded:

    <p><script type="text/javascript" src=""></script></p>
    This is what's actually inside of list.js (there is JavaScript mixed with PHP):

    document.write('<style type="text/css">option {padding:1px 3px; }</style>');
    $db = new Database();
    if (!$db->connect($db_host, $db_user, $db_pass, $db_name))
    $sql = "SELECT id, proxy, hits, time
                    FROM {$db_tp}proxy
                    ORDER BY time DESC
                    LIMIT 0, 50";
    $res = $db->query($sql);
    document.write('<form method="get" name="form" action="http://www.<?php echo $cfg['domain'] ?>/redirect.php" target="_blank" style="border:1px solid #ccc;padding:3px 0;font-size:10px;width:190px;text-align:center;">');
    document.write('<b title="All Links Open In New Window/Tab">50 Newest Proxies</b><br />');
    document.write('<select name="id" size="12" style="width:180px;border:1px solid #ccc;margin:3px 0;" onclick="document.form.submit();">');
    while ($row = $db->fetch_assoc($res)){ ?>
    document.write('<option value="<?php echo $row['id'] ?>"><?php echo rtrim(str_replace(array('http://','https://','www.'),'',$row['proxy']),'/') ?></option>');
    <?php } ?>
    document.write('</select><br /><a href="http://www.<?php echo $cfg['domain'] ?>/" title="Get A Free List Widget For Your Website or Blog!" target="_blank" style="color: black; text-decoration: none">Powered by <?php echo $cfg['domain'] ?></a></form>');
    I'm not sure if this is a server problem, a browser problem a JavaScript problem or a PHP problem.

  2. #2
    The .js file isn't parsing the PHP. Try adding this line below in your .htaccess?

    AddHandler x-httpd-php5 .js
    It may depend on the server config on what the exact line is and you could also match just the specific filename to be parsed.
    Programmer, web developer and entrepreneur.

  3. #3
    .htaccess doesn't seem to respect AddHandler on my server. However, renaming list.js to list.php worked like a charm: test

    I think if the script is changed to do it this way, it would be more compatible with various servers.

    I also added these lines to .htaccess:

    RewriteRule ^list.js list.php [QSA]
    RewriteRule ^listblack.js listblack.php [QSA]

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts