Results 1 to 3 of 3

Thread: list.js Widget from atProxy Not Showing Up

  1. #1
    vectro's Avatar
    vectro is offline I Like Stuff
    Join Date
    Dec 2008
    Location
    U.S.A.
    Posts
    625
    Thanks
    192
    Thanked 100 Times in 79 Posts

    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:

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

    Code:
    document.write('<style type="text/css">option {padding:1px 3px; }</style>');
    <?php
    
    require('./includes/config.php');
    require('./includes/functions.php');
    require('./includes/database.php');
    
    $db = new Database();
    if (!$db->connect($db_host, $db_user, $db_pass, $db_name))
            pretty_death($db->error);
    
    $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();">');
    <?php
    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
    Nathan's Avatar
    Nathan is offline Work!
    Join Date
    Dec 2008
    Location
    New Zealand
    Posts
    392
    Blog Entries
    1
    Thanks
    37
    Thanked 120 Times in 68 Posts
    The .js file isn't parsing the PHP. Try adding this line below in your .htaccess?

    Code:
    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. Thanked by:

    vectro (5 December, 2011)

  4. #3
    vectro's Avatar
    vectro is offline I Like Stuff
    Join Date
    Dec 2008
    Location
    U.S.A.
    Posts
    625
    Thanks
    192
    Thanked 100 Times in 79 Posts
    .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:

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

Tags for this Thread

Bookmarks

Posting Permissions

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