• I’m not sure how to explain what I want to do and I’m not sure I would understand many of the answers since I’m quite new to this. I’m no slouch when it comes to hardware and operating systems, but coding is not my thing.

    That being said, I have managed to set up my own server, get WAMP working, launch a self-hosted WordPress site, get all my tricks moved over from a hosted provider to my server and working in wordpress, make the little changes I wanted .. I’m happy with what I’ve got. However, there’s one thing I’m trying to do and I’m going to have to explain a bunch of things so everyone understands what I need and where my struggle is.

    I run a streaming radio station. I’m using RadioDJ. RadioDJ has a REST server built by one of their community members who’s fallen out of contact, so they’re no help. They wrote a bunch of PHP files so that the Server RadioDJ can be messed with remotely. I want my DJ’s to be able to log into our website, which will give them access to a special link (I got that much to work) and they can then turn off the AutoDJ on the server and clear the Playlist so they can play their own stuff. The REST Web Panel allows this all to happen, however, I can’t get it to run on our website. It’s a handful of PHP files, some are in folders (assets and includes) and I’d like to just get this jumble of PHP files to run on a single page.

    I got it sort of working at one point, but it wouldn’t load the style sheet and none of the “buttons” worked, but it WAS executing the index.php file and that was about it.

    If you were able to wrap your head around this nonsense I just dumped here and think you can help, I can answer any additional questions that are needed.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Moderator bcworkz

    (@bcworkz)

    If the REST Web Panel worked without WP, it still should work without WP. This would mean that logging into WP would not have any effect on RadioDJ access, it’s a completely independent app, presumably with it’s own access control. It would also have it’s own stylesheet that probably has no relationship with your WP site. Since it is not a public page, how important is that?

    That said, it should be possible to integrate the REST Web Panel into the WP. How difficult that is would depend on how the RadioDJ code is set up. The way to start is to convert whatever .php page that constitutes the main Web Panel page into a custom WP page template. Page templates are part of your theme. To avoid the risk of custom work being lost when the theme is updated, a child theme should be created.

    Converting a .php file into a template is mainly a matter of adding a specific comment header at the top of the file and locating it in the child theme folder. The comment is something like /* Template Name: Web Panel */ With that in place, create a new WP page and select the “Web Panel” template. The only other requirement is to assign a title. Publish the page. The web panel is then accessed through this page’s permalink.

    This page will still not appear like other WP pages unless calls to get_header(), get_footer(), and maybe get_sidebar() are added. The main HTML containers in your theme’s page.php file would need to be replicated for main content to be styled as other WP pages. The original code likely loads other PHP code pages with statements like include, require, include_once, or require_once. The correct relationship to these other files needs to be maintained, either by moving the other files or by correcting the references.

    To restrict access to this page, it can be password protected, or restricted by user role or capability. The latter can be achieved by adding something like if ( ! current_user_can('manage_options')) wp_die('Insufficient permission');

    That is the basics of integrating existing PHP into WP, but many other adjustments may be required, or that may be all that’s needed. To achieve proper integration, you may need professional assistance. Experts in working with WP can be found through jobs.wordpress.net.

    Thread Starter lyniaer

    (@lyniaer)

    Thank you for the information. I could follow just enough of it to know I’m probably in over my head, but it sounds like you’re familiar with RadioDJ?

    Here’s a link to the REST Web Panel with a screen shot of what it should look like and the files to download if you wanted to look at them.

    I checked out that jobs.wordpress and I might post in there if this is excessively complicated. This is definitely something that needs to happen, though, so I can get my DJ’s moved over to the new software and off the problematic SAM Broadcaster.

    Moderator bcworkz

    (@bcworkz)

    No, I knew nothing of RadioDJ. I was going on what I knew of typical PHP apps and made some educated guesses. Thanks for the link, seeing the actual files gives me a better idea of what may be involved.

    It does appear it can be integrated into WP, but it will take some modification. Besides what I mentioned previously, there could be some jQuery conflict, depending on what your theme does with it. This too can be resolved. It appears the app is largely jQuery driven, the PHP serves more as a scaffold than anything else.

    You might consider running outside of WP just to get it up and running quickly. Better integration can be worked on in the mean time. I’m not sure how the public site would interface with the RadioDJ stream, but there ought to be a way. Another possibility for quick integration would be to run the app outside of WP but run it’s display through an iframe on a WP page.

    Thread Starter lyniaer

    (@lyniaer)

    I wouldn’t even know where to start with the iframe thing. I know what they are and I know how to integrate them, but writing them is a bit outside my wheelhouse. I love learning new stuff and I can work on cars, computers, electronics; I can solder, work a multimeter and spank Windows like nobody’s business (I can work with batch files and HTML3!). Never elevated my programming skills beyond that. If I had hair to tear out, trying to wrap my head around HTML5, Javascript (jQuery, JSON, that’s all Java, right?), PHP – I’m pretty sure I’d start flaying my own skin.

    I wandered into this self-hosting website thing out of necessity to keep my overhead to a minimum and I’m pretty sure it’s only working because I got drunk and screamed at the monitor for three hours. That might also explain the teeth marks on this keyboard… It’s all kind of a blur.

    I can get the interface to come up if I navigate to it via LocalHost, but in order to make it reachable from the internet I would have to set up another virtual host in Apache, right?

    When I got it half working, all I did was use .. umm .. I forget what they’re called. A code thingy. A custom field that called the index.php file of this mess. I think the problem is, once it calls the Index file it doesn’t know where to go to call the other files (like functions or config) and I would need to go into every single file and point it to the proper directory. That’s what it looked like to me during previews. When I call up the page in Chrome and check the Developer console, it shows me that it’s having 403 errors trying to reach the style.css and other things. It will show the buttons (play, stop, autodj, etc) but there’s no colored bars, the words are shoved all along the left hand side of the page, the mouse reacts like there’s something to click but clicking on play or stop does nothing. Index contains the words of the buttons, but other PHP files indicate what those buttons do, so that’s where I’m coming to this conclusion that it can’t call the other files.
    Isn’t there something you can put at the top of a PHP file to force it into a directory?

    The style.css handles the color and size of the buttons. I think that’s one of the problems you mentioned – the style of this web panel might interfere with the style of my website.

    Moderator bcworkz

    (@bcworkz)

    A basic iframe is just HTML like this: <iframe src="http ://example.com/"/> (without the space before the colon. I hate the way this forum’s parser “linkifys” properly formatted example links. You’re not the only one with quirks πŸ™‚ ) But getting the iframe to look right will take more effort, mostly CSS. But what ever that example link really is of course needs to work correctly on its own.

    There may be nothing wrong with the links to other resources. 403 errors are a file permissions issue. Usually, folder permissions should be 755 and files 644 on ‘nix systems. Straightening out permissions may be all that is necessary for functionality. While it’s fine to test your installation on localhost, you do not want to allow public internet access to it unless you are an expert in public web server management. I fully understand the need to keep costs down, but leasing space on a shared commercial server is money well spent. As long as your traffic load is within reason, it need not cost that much. As you are running a streaming service, you’ll need to make some reasonable estimates on total bandwidth. You don’t want to go over, but you don’t want to buy more capacity than you need either. In any case, I don’t think a typical home computer setup is going to be able to handle a public streaming service for a number of reasons.

    The reason to add a virtual host is in part so you can use your domain name locally so when the site is moved to a commercial server you don’t have to change any internal links. It does not enable public access, that is a different process, which you should avoid IMO.

    The help page for RadioDJ says it is powered by Simple Machines Forum. If that’s the case, why use WordPress at all? Will RadioDJ provide enough functionality without SMF? Or is it a prerequisite? I initially thought RadioDJ was a stand alone package. If it needs SMF, integrating with WP seems very unlikely, though you can certainly have two separate packages running in a single website. They can be styled to appear similar, and interlink to each other, but they cannot be fully integrated.

    Here’s what I suggest you do first. Resolve the 403 permissions errors by confirming all folder and file permissions are as previously stated or correct for your O/S. Ensure Apache is running as the user that owns all Apache related files. The user is set in the Apache configuration file, usually httpd.conf.

    Determine what else is needed to get RadioDJ working since it appears to be critical to the entire projects. Everything else can be managed somehow, but without RadioDJ you will need an entirely new plan.

    Thread Starter lyniaer

    (@lyniaer)

    Website works fine. http://www.radio-takeover.com
    RadioDJ also works as you can pull up the stream on the website. It’s all been working for a few months, now.

    I have other DJs that are raring to start their own shows, but here’s the problem:
    There’s no way to stop the RadioDJ software that’s running on the server so other DJs (elsewhere in the world) can connect to the Shoutcast stream and do their own shows.
    This Web Panel allows remote access to the RadioDJ software on the server so that one can 1) Stop the AutoDJ from assigning more songs to the playlist, 2) Time the end of the current song with the start of their show so there’s no awkward transition and 3) Kick the Server off the Shoutcast stream so that the DJ can connect and run their show.

    The only way we can do it right now is I either have to be here to do this manually or give them Teamviewer or RDT access to the server to do it themselves. And it’s an actual Server that I use. Dual Processors, Boatloads of RAM, physical firewall, yadayadayada and 230Mbs D/S 25Mbs U/S connection.

    As for the 403, I learned all that with a Google search a while back. I did everything I could think of, including taking ownership, granting permissions, etc. style.css and one other file (I think it was the icon file) were still barred from running on the page, it was baffling. This is why I like hardware. It works or it doesn’t, but science always dictates why. Networking and Coding often work (or don’t work) depending on if Jupiter is in Retrograde.

    Moderator bcworkz

    (@bcworkz)

    OK, I got RadioDJ itself and Web Panel conflated together in my mind. I kinda understand the difference now. Definitely all new to me. The fact remains we need to get rid of 403 errors in Web Panel. You can allow outside internet access to localhost if it’s on a fixed IP address and the Apache configuration is setup to allow it. But you don’t want just anyone to access it, only your DJ’s. If they are on fixed IPs, you can whitelist their IPs in Apache. They probably have dynamic allocation though, so their IP changes from time to time. I’m not a security expert, so I’m unsure of good alternatives. All I really know is you need good security with external access.

    All I can tell you about the 403s is the Apache user specified in its configuration file needs to be the file and folder owner within Apache’s realm. If you change anything in the configuration file, you need to restart Apache. How the owner is set depends on your O/S. Commercial servers often run the mod_security module that can cause 403s even with correct ownership, but you wouldn’t be running it on localhost I should think. If it’s loaded, it’ll be in the configuration file somewhere.

    Thread Starter lyniaer

    (@lyniaer)

    Okay. Going back through the process, here’s what is happening:

    1) Create a page
    2) Activate this plugin.
    3) Insert this code into the page:
    `<?php
    require_once(ABSPATH . ‘REST/index.php’);
    ?>`
    4) This is the preview result in Chrome with F12 Console open:

    Desired result is here (from localhost connection):

    • This reply was modified 9 years, 2 months ago by lyniaer.
    • This reply was modified 9 years, 2 months ago by lyniaer. Reason: Pasteboard, you have failed me for the last time
    • This reply was modified 9 years, 2 months ago by lyniaer.
    Moderator bcworkz

    (@bcworkz)

    You can use that plugin if you want, it’s your site. It introduces security vulnerabilities that are easily avoided by introducing PHP properly. It’s basically a crutch for those unwilling to learn about the Shortcode API. Shortcodes achieve the same end without any vulnerability.

    In any case, introducing the the panel that way will not work without a lot of adjustments because the relative paths to other resources will be wrong. IMO the best way to introduce the panel into the site is through a HTML iframe. This solves all the relative reference issues since the panel is running in it’s own space, the iframe is essentially creating a remote viewport to the panel running normally outside of WP.

    Thread Starter lyniaer

    (@lyniaer)

    “Shortcode”. That’s the word I was looking for earlier. Yeah, I turned it off. The iFrame you suggested works great with the “src” as a LocalHost address. Now I just need to get it set up WITHOUT using LocalHost so it will be accessible from the internet.
    Any quick and dirty ways to do that? So far all I’m finding with my GoogleFu is using Multisite.

    Moderator bcworkz

    (@bcworkz)

    Hmmm. I’ve always been focused on keeping people out. I believe it’s a matter of using the right IP addresses. Your internet gateway needs to be on a fixed IP. That’ll get the outside to your router. I’m not sure how packets get to the actual computer from there. Some sort of port forwarding setup in the router I think. Then the IP you use for WP is the LAN address, usually something like 192.168.0.x.

    If you search for information on setting up a web server on a LAN, you should get better information than I can give you. Good luck!

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Execute multiple PHP files on a single page’ is closed to new replies.