My friend and I wrote a webapp in php for school. The app was supposed to work with Ibeacons but we just figured out that we can't link an external beacon CMS to a form, which was what we were planning on doing. Instead we're thinking of rewriting all the php code that pulls records from the database and shows it on the webpage. If we get rid of the php and compile it to a mobile app with a program like Phonegap we might be able to integrate beacons in the app.
I've been looking everywhere to find an easy way to rewrite the php code to JS server pulls, with no luck. at the moment we're using a local database but we want to transfer it to a server.
What would be the best way to translate the php code? We have no idea how to start.
Here's an example of our PHP code we're trying to rewrite.
<?php
session_start();
include("config.php");
include("Classes/event.class.php");
if(!isset($_SESSION['loggedin']))
{
header('location: login.php');
}
$event = new Event();
$uid = $_SESSION['u_id'];
if(!empty($_POST))
{
$foto = $_FILES["file"]["name"];
$event->Foto = $foto;
$tmp_name = $_FILES ['file']['tmp_name'];
$error = $_FILES['file']['error'];
if (!empty($foto))
{
$location = 'noteimg/';
if (move_uploaded_file($tmp_name, $location.$foto))
{
}
}
$event->Title = $_POST['titel'];
$event->Teaser = $_POST['teaser'];
$event->Link = $_POST['link'];
$event->Beacon = $_POST['beacon0'];
$event->EndDate = $_POST['enddate'];
$event->save($uid);
}
?>
That's hard to achieve in an automated approach.
Maybe php-express module could be useful to directly execute some chunks of php code.
But I thing you should refactor allmost all application structure. Specially all parts regarding routing or dealing with http headers, etc...