Getting the client hostname in to Javascript using PHP

So I dont know how often this comes up for other coders, but it comes up often enough for me to want to make note of this process.

This method only works if your parsing you code as PHP.

First create a simple index.php file and add the following code to it.

And that’s it. You now have the host name of your client set in the Java Script var clientHostName. Easy!

Just an update..

Its been q while since I had anything interesting to post up here so I thought I would do a catch up post for ya’ all.

Firstly I am still employed full-time as a coder. I develop client/server apps. Currently I am working on version 3.1 of PHP Season Pass The planned Java version (SkiPos) has been put on hold indefinably due to some people not being able to deal with change or new things and demanding to stick with the decades old systems they have. Not up to me that one. I do want to see it finished. If there comes a time I have nothing to do I’ll put some effort in to getting that compleated. The latest version of PHP Season Pass has a few changes to the data base and order management system to 1, limit orders to one per seaon per member 2. I ahve added the ability to sell products for any future season along side current season products on the same order. Talk was to make it so users would have to create orders for next seaon in this one was shot down by yours truly as the problems this would cause just grew in number the more I worked through the idea. With the creative use of accounting terminology and programing slite of hand I proved my solution to be the better and soe implemented it. All of 15 lines of code that it turned out to be. I have also improved the ‘on order member edit’ functions. Users can now edit member account details, clone members and take or upload member pictures right from the main order page. This was done with the addition of new Javascript and ajax code and a huge amount of testing. first opinions are that its sweet and will save a lot of time and prevent many of the problems users where having with duplicate member accounts.

OSD development is now on hold also. The users it has are happy with its current functionality so why poke at it. Further development of OSD will be on a per client request basis. Solutions developed for clients that are deemed to befits all users will be pushed up to the main branch where possible and practical. Also note that if no further development of OSD is requested by this time next year I will release OSD as an open source project for anyone that wants it.

As you may have seen here, I have started work on a game project called Dyson Wars. Dyson Wars is now my flag project. Details of it and the dev process can be found at Please check it out as I think its going to be an awsome game when compleated.

Lastly is my ‘tinker’ project called Survive this then! No site or devblog for this one yet. Its been in development for about three months now and I plan on a release just before Christmas this year. STT! is a top down 2.5D puzzle/shooter for the android and Windows markets. Simple in design and game play but massive on innovation and adictiveness. Using your own music play lists, this game tailors its graphics, game style and tempo to you. You decide what music you want in your play list and the game speed adjusts to match the beats of your tunes as you play. Play fast rock and get alien invasions, play classical and get butter flies and tweety birds. Play punk and get skin head mashers chasing you as you work to solve puzzles and earn coins to buy power ups and solutions or even new play styles when more are added. I plan on pushing out a simple limited/add supported version for free with the full version selling for around $2.00. The paid version will include more game themes, no adds, cheaper power ups and more levels.


JMonkey Engine 3 : Example of vertex docking ( snap to grid ) mouse picking and more

Here is a test app to help explain how to find a vertex in a geometry and attach another geometry to the vertex…..

All that code below will give you something like this:

what it shows you...
what it shows you…

Check out the comments in the code for details on whats going on, but use the left mouse button to drag the yellow ball. The red arrow shows you where the pick is currently on the surface of the sphere. Release the mouse and the yellow ball sticks to the sphere. Enjoy. Press T to toggle snapping and watch as the yellow ball jumps from vertex to!.

UPDATE : I found an issue in my first version that caused the yellow ball to be placed in the wrong location if the picked geometry was moved from 0,0,0. This version shows how snapping can be done between separate geometries. I intend to write a better demo to show how to move nodes around and dock them to other nodes using this method. Watch out for that next week.

The Main file. You will need the mouse sensor control below also.

JME 3 orbiting nodes

Hi, well I have started learning to use the JME3 engine and I must say for what I have seen so far its vary good. There is, as with anything like this a bit of a steep learning curve, but its not too hard and there are plenty of docs and tutorials on the web.

So the point of this post is that I solved my first problem in JME3 that I thought was noteworthy. I’m just messing and learning at the moment and one of the things I wanted to try was to build a simple solar system complete with a star, planets and moons. The first two parts where easy, but getting the moons to orbit the planets as desired caused me no end of head scratching. I posted up and the JME forums to ask for advice and got it. The advice was that I was doing to all wrong. Ha! so I started over and took the pointers I was given and came up with the code below. If you have the JME3 SDK you can run this and it will show a very simple system with a sun and a planet and moon orbiting as they should. I’m posting this because I think its something others could use and will save them days of frustrations.


 package mygame;

import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings;

 * test
 * @author normenhansen
public class Main extends SimpleApplication {

    public static void main(String[] args) {
        Main app = new Main();
        AppSettings gameSettings = new AppSettings(false);
        gameSettings.setResolution(1680, 1050);

        gameSettings.setTitle("Dyson Wars");
        app.settings = gameSettings;

    private Node sun; // the sun
    private Node planetOrbitNode; //the planets orbit node
    private Node planet; // the planet
    private Node moonOrbitNode; // te moons orbit node
    private Node moon; // the moon

    public void simpleInitApp() {
        cam.setLocation(new Vector3f(0, 0, 20));
        cam.lookAt(new Vector3f(0, 0, 0), Vector3f.UNIT_Y);

        Node system = new Node("System");
        sun = new Node("Sun");
        Geometry g_sun = new Geometry("Sun", new Box(0.5f, 0.5f, 0.5f));
        Material m_sun = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        m_sun.setColor("Color", ColorRGBA.Orange);

        planet = new Node("Planet");
        Geometry g_planet = new Geometry("planet", new Box(0.5f, 0.5f, 0.5f));
        Material m_planet = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        m_planet.setColor("Color", ColorRGBA.Green);
        planetOrbitNode = new Node("PON");
        planet.setLocalTranslation(0, 3, 0);

        moon = new Node("moon");
        Geometry g_moon = new Geometry("moon", new Box(0.25f, 0.25f, 0.25f));
        Material m_moon = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        m_moon.setColor("Color", ColorRGBA.DarkGray);

        // attach the moon to its orbit node
        moonOrbitNode = new Node("MON");
        moon.setLocalTranslation(0, 1.5f, 0);
        // attatch the moons orbit node to the planet



    public void simpleUpdate(float tpf) {
        this.moonOrbitNode.rotate(0, 0, -0.002f);
        this.moon.rotate(0, 0, 0.001f);
        this.planetOrbitNode.rotate(0, 0, 0.001f);
        this.planet.rotate(0, 0, 0.001f);
        this.sun.rotate(0, 0, -0.002f);

    public void simpleRender(RenderManager rm) {
        //TODO: add render code


So I’m guessing anyone who deals with API’s or data from other applications will need this at one point or another. What this does is extract data from a string between the given start and end tags with the option to start the search at any point in the string.

	 * function to return a string from within another string
	 * found between $beginning and $ending
	 * @param string $source
	 *        	the string to search
	 * @param string $beginning
	 *        	the string that marks the start of the text to extract
	 * @param string $ending
	 *        	the string that marks the end of the text to extract. Default = 0
	 * @param string $init_pos
	 *        	the int possition of start searching from
	public static function get_middle ($source, $beginning, $ending, $init_pos = 0) {

		$beginning_pos = strpos ( $source, $beginning, $init_pos );
		$middle_pos = $beginning_pos + strlen ( $beginning );
		$ending_pos = strpos ( $source, $ending, $beginning_pos + 1 );
		return substr ( $source, $middle_pos, $ending_pos - $middle_pos );