Phonegap app on local network - php

I developed a scan app with phonegap which scans a code, then does an Ajax call to my website which let's the app know whether or not the code is valid (this info is stored in a mysql database).
Now, I want the same functionalities, but on a local network. So I have a computer running a local server using xampp.
It should be possible to take this setup and place it on a different location (so the ip of the computer can change or should be locked or something).
Anyone who can point me in the right direction, I'm pretty clueless...

Related

Access files in remote computer with php

I need to create an application using php which is hosted in a server and need to communicate with a csv file located in clients local machine. Is there any way we could do this ? How can I connect to a remote csv file ? Is this possible ?
Server machine accessing a csv file directly from a client machine is not a good idea. It's a security threat indeed. Consider you are navigating some website and it's server is able to access your computer's file system!!!
There are various alternatives to achieve this, some of these might be:
Make the user upload csv files to server in order to make it
available to the server application
If the client and server are in the same network, then share the
folder on client machine to make it accessible from the server
etc... I would have preferred the first option as mentioned above.
As #AnthonyB mentioned in comment under your question, server can't directly call client, and that is true. Server is called "server" as it serves requests from the client.
To be able to give away files to remote requests, your client needs its own server application, like Apache HTTPD for example.
In case if you need continuously request client's server to collect files with your PHP server, what you are looking for called "worker". One of AWS tools called Elastic Beanstalk offers possibility to choose a server or a worker application during start up wizard for PHP. It is pretty straight forward and easy to use.
Please note, that your client must have dedicated IP address or use Dynamic DNS approach by pushing its IP to a DB (or directly to a server) where worker will take it from.
If you don't need dedicated worker, you can configure CRON JOB to send requests to clients server applications.
IMHO, all that scenario worth it only if you are building corporate grade application. In most cases (and if you do REALLY need to collect files from clients) you have to install Apache + PHP server on the client side and make this guys to wait for request from YOUR remote php server. Without it, you can not get files from clients computers via browser without user input interactions. At least legally :)

Using my php scripts in Android to access database

I need some major help in setting up my android app to add/receive data to/from my database. I'm using Amazon's RDS service in connection with xampp's phpMyAdmin. I've already successfully connected my DB instance to the database in phpMyAdmin. Also, I've written my php scripts to do basic CRUD (Create, Read, Update, Delete) commands in SQL. I've been following this tutorial.
The problem for me is, in his tutorial he is using strings like this:
private static String url_all_products = "http://api.androidhive.info/android_connect/get_all_products.php";
to run his php scripts in a call to makeHttpRequest(url_all_products). But I don't have my own website to do this and I'm pretty sure I don't need one to do this.
Next, I have a test.php file that does a simple echo statement and it works when I run this in a web browser:
http://localhost/phpfiles/test.php
Which leads me to my second problem. I don't want to use localhost because I need these php files and the ability to retrieve data from the database to be accessible to anyone using my app. This is the sole reason I'm using Amazon's RDS service so my database can be accessed on the cloud.
So how can I use the host address provided to me by Amazon RDS to access the database and where do I store all the php files so I can properly use them in Android the way the tutorial shows? They are currently saved in xampp/htdocs/phpfiles/.
I feel like I'm missing some fundamental understanding of all this and I'm going about it all wrong. If someone can point me in the right direction that would make my day.
It sounds like you don't really need the XAMPP install on your local machine at all. You're hosting this on Amazon and you want it to be available to the internet, so your local computer isn't involved. You can use XAMPP locally for testing and development, but for production use you'll be exclusively on the Amazon RDS cloud.
But I don't have my own website to do this and I'm pretty sure I don't need one to do this.
You may not want a website, but you do want your services hosted on the internet. That's what your RDS instance is for, and technically the tutorial is referring to an API which happens to be exposed through a web page. This is a much better idea than opening MySQL directly to the internet on port 3306.
You'll then use your Amazon host — for which you really should use a FQDN such as api.example.com rather than the IP address, but the IP address will work just fine from a technical aspect.
The files you refer to are on your local XAMPP installation; in the xampp/htdocs/phpfiles/ folder, and need to instead be on the RDS instance.
Then your application accesses the API you expose in those files which return information back to your application.

Running Local webserver on pc or Raspberry Pi while protecting source code

Hello Stackoverflow community :), i really need your advice regarding this issue.
I have developed a software in php/mysql+(js/css) to help me manage my office practice.
I want to:
Setup a local server # my office,
Problem :
I dont want anyone to get access to my php/mysql files.
can i :-
have a dedicated pc / or Raspberry pi running local server and connected to my wifi with static ip running 24/7 and yet it can automatically restart web server if power down and run server up again without need to enter password. while at same time restricting direct access to read/copy source code files on it -incase some one tries to copy them- ?
My web application traffic is 4-5 devices # most -tablet/pc's -, yet my application is a bit complex and run lots of data analysis and data mining and its mysql database is growing (50k+ rows in 20 tables)
Optimum solution i would think of is an OS including my server and all its files encrypted and secured against copy/read, once it power up it only brings a web browser directed to the local server web page and that's it.. no any other operation allowed by the normal user other than using browser and connecting to WiFi.
can it be done with windows/ ubuntu or any other distribution of linux ? server folder and xampp be given admin privileges and encrypted and auto run on system start-up even if admin does not log in (in case computer restart while i'm not # office) and normal guest user can use computer as much as he want as long as he is not touching my xampp folder
This can also be useful for developers struggling to sell php applications without giving out source code
You need to take into account that as soon as someone has direct access to the raspberry pi SD-Card he can easily get the root password as well as any password to your encryption solution as long as the password is saved on the card.
If you want to be really secure you need sort of dongle your sd card with the raspberry pi to make sure that the encryption can only be done if the sd card is entered in that specific pi and you need to encrypt the whole sd card.

Offline Mode - Updating data once internet is connected

I am just looking for advice on the feasibility of implementing this and any general ideas and suggestions on whether this is possible. NOT code and this is not homework.
I'm developing an online application for fitness, and, to and from the gym I usually have no internet connection and therefore have to wait until I return home / have internet connection before I can enter all the data for that particular day and any notes.
I'm wondering whether or not it would be possible to somehow develop an offline mode where I can still enter the data and then when I return home, and, connect my laptop to the internet the data will then be uploaded to the server so I don't have to re-enter the data when I get home?
Thoughts
My general thoughts would be to place the data inside a cookie, but, I'm not quite sure how the cookie will update itself once the internet has come back.
Another thought would be to use sockets, and, then interact that way. In that, my web-server has a cron job that "Seeks" whether data is available from a particular IP on the network (Again, the server will be on the same network) and if there is, then, the system will transfer the data from my local machine to the web server.
Any ideas of your own will be greatly appreciated.
You can run a web application offline by using your computer as a server, you can get PHP stacks like the ones listed below that run apache, php and mysql.
Windows: WAMP, AMPPS
Mac: XAMP, MAMP
Then, you can save all your important data to a CSV file, and once your online your script can push the CSV data to your remote web server.
You can check if your online by pinging google or something.

is it possible to create a system that is connected a website with the same database

Good day. I have a thesis project. it is composed of a webpage created on php and a system using vb.net 2008.
As of now , they are both connected to the same database.
I am wondering if it is possible that if i packaged the system and live the website, will still be connected with one database? Thank you in advance.
If I understand you right (and the question could be better worded), you're asking what happens if you deploy the website on a different server than the one you used to develop it. The short answer is that, unless the machine hosting the database is accessible to the web server host machine, that you would also have to redeploy the database.
In other words, wherever you move the PHP-based website and VB.NET system, they would need to be able to access the machine hosting the database server. Otherwise, I see no issue with them both accessing the same database.

Categories