I would like to create a simple notification icon that would display a number in the users system tray.
The application only needs to allow the input of an API key that it would use to fetch information from the server. So, for example:
http://www.example.com/api.php?key=dfg45tgyy67h
The PHP file will return two values, a number, and a URL. The number should appear in the system tray, and clicking on it should take you to the URL. The application should update the information at a specified interval, which can be hard-coded into the application.
I really have no idea how to do this, but can pick up things like this pretty quickly. So I would like to know some ways to accomplish this, or what the easiest method to use would be.
EDIT When I said PHP what I meant was that on the server it would be a PHP file serving up the information to the application. I didn't plan on creating the client application in PHP.
You can't do this with PHP as it has no way of interacting with a user's computer and and that includes the system tray. You'll need to write something that will run on their computer and then polls your PHP script for this information.
Use a cross-platform language and widget toolkit with both browser launching and system tray capabilities.
Related
I want to implement a simple long polling system in PHP. A simple Szenario:
The Project is based on two websites. Website A and Website
B. There are two Users. One on Website A (UserA) and one on
Website B (UserB). On the Website A is a Button. If UserA push the
Button, the color of Website B change instantly.
Of course i can do this with a MySQL Database, but this seems way to big, because i just want to transfer one Bit.
Are there any other oppurtinitys to store one Bit on the Server an have acces from all PHP Pages, which are hosted on the Server?
I thought i could use a simple .txt file, but i am not shure if the Server Crushes if two diffrent Websites want to access to the same file. Is this a problem?
Or have you any other Ideas how to resolve it?
I would not recommend using a text file, since I/O operations is pretty slow compared to other methods.
You have to read the file on every page load/refresh or even worse, with an ajax request to do it instant. I think I would recommend something like Redis / Memcached and make some sort of ajax call to read from that (if you want it to be instant).
If you don't have access to the server, to install that kind of software, I would use a MySQL database.
Hope it helps
I'm creating a website that requires a file to be generated and stored on the server periodically (an XML feed for iTunes). The page is generated using ExpressionEngine. I discovered that the website's current server has a very restricted cPanel and doesn't have access to cron.
So I'm considering two options; find an alternative way to access the cronjobs (if they are available), or find an alternative way to created regularly scheduled tasks.
Regarding the first option, how would I go about determining if a server has cron available? I'm not sure how useful this would be anyway since I don't think the server allows shell access (it's a very basic setup for people who aren't tech savvy).
Regarding the second option, a friend mentioned to me that the functionality of cronjobs can just be done in PHP. How would I go about this?
Or, am I perhaps thinking too much with this? The page in ExpressionEngine that outputs the XML file is domain.com/itunes/itunes_feed. This just has some EE tags that outputs the relevant XML and the resultant page is in .xml format. Is it enough to just submit the above url to iTunes, or does it have to be a url to the actual pre-existing file on the server?
Option 1
Simply contact your hosts and ask them do they support cron jobs, and if so, how to set up.
Option 2
I only just set up my own set of cron jobs yesterday..
Create a php file that runs the code you want,
Set up and account on https://www.easycron.com/
Upload your php file to easycron
Set the times in which you would like your php code to run
Simple as that! Does that make sense?
I have a program that users want to download. Instead of offering a link to download and they download the program and enter the information, I would rather have my PHP script do it.
My website requires a username and password to login, there is a private page where a user can download a file. When a user goes to the "download" page, there is specific options on the page the user must choose. Once the choices are selected and the user clicks "Download", I want PHP to go to my programs source, add the missing data inside the source, compile it into a .exe, and bring it back to the user.
Thing is, I have no idea how to do this and im scared that PHP will put the information for one user and accidently give one users information to everyone else.
How can I make it that each binary is different?
I'm currently making my program in Windows (using Code::Blocks) but im going to be hosting the files on a Linux or FreeBSD server. Just wanted to let that out incase there is something I need to know.
Since you're in effect allowing the user to enter arbitrary code onto your server, this seems like a serious security risk. Why is customization of the executable needed? Could it be a configuration file?
If you want to go ahead with this, it can be done pretty easily. Perhaps use a templating engine like Mustache (not the C++ language feature templates). Write your source files to include this mustache templates.
When the user has posted the info, you just need to run the command to apply the template to get the finished source, then run your makefile to generate the finished executable. Then you can give it like anything else.
If you want to make sure the users can't get the same binary, an easy way would be to delete the finished executable after each run. There's better ways of doing this, but this is easy.
I have a list with my employers project task list. When a user adds a new project to the list, I want to push some of the data the user entered into an external site (which is run by our parent company) to store in a separate project management system.
So my question is:
Is there som way to post data (some or all fields) to a PHP-script on an external server?
I don't have any programming experience with SharePoint (or .NET in general), so if this is something that can be done with Workflows I would be very happy.
As far as I'm aware there's no mechanism in SharePoint that would allow you to make a request to an external site when a list is updated.
Depending on how quickly the data added in to SharePoint needs to make its way in to the project management system, a polling solution may be your best bet.
Just create a PHP script that will pull the list from SharePoint and check for any changes (pushing them to your Project Management System is found), then setup a CRON job to run the script at given interval's (Hourly/daily etc depending on how quickly you need the changes to take effect)
Anyways, hope that helped somewhat :)
Look into List event handlers, you can attach event handlers on list item updates/adds etc.
http://blogs.msdn.com/b/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-you-need-to-know-about-microsoft-office-sharepoint-portal-server-moss-event-handlers.aspx
you will need a way to communicate with the php system (web service or database insert/update via c#/vb.net code.
I'm playing with an embedded Linux device and looking for a way to get my application code to communicate with a web interface. I need to show some status information from the application on the devices web interface and also would like to have a way to inform the application of any user actions like uploaded files etc. PHP-seems to be a good way to make the interface, but the communication part is harder. I have found the following options, but not sure which would be the easiest and most convenient to use.
Sockets. Have to enable sockets for the PHP first to try this. Don't know if enabling will take much more space.
Database. Seems like an overkill solution.
Shared file. Seems like a lot of work.
Named pipes. Tried this with some success, but not sure if there will be problems with for example on simultaneous page loads. Maybe sockets are easier?
What would be the best way to go? Is there something I'm totally missing? How is this done in those numerous commercial Linux based network switches?
I recently did something very similar using sockets, and it worked really well. I had a Java application that communicates with the device, which listened on a server socket, and the PHP application was the client.
So in your case, the PHP client would initialize the connection, and then the server can reply with the status of the device.
There's plenty of tutorials on how to do client/server socket communication with most languages, so it shouldn't take too long to figure out.
What kind of device is it?
If you work with something like a shared file, how will the device be updated?
How will named pipes run into concurrency problems that sockets will avoid?
In terms of communication from the device to PHP, a file seems perfect. PHP can use something basic like file_get_contents(), the device can just write to the file. If you're worried about the moment in time the file is updated to a quick length check.
In terms of PHP informing the device of what to do, I'm also leaning towards files. Have the device watch a directory, and have the script create a file there with something like file_put_contents($path . uniqid(), $command); That way should two scripts run at the exact sime time, you simply have two files for the device to work with.
Embedded linux boxes for routing with web interface don't use PHP. They use CGI and have shell scripts deliver the web page.
For getting information from the application to the web interface, the Shared file option seems most reasonable to me. The application can just write information into the file which is read by PHP.
The other way round it looks not so good at first. PHP supports locking of files, but it most probably doesn't work on a system level. Perhaps one solution is that in fact every PHP script which has information for the application creates it own file (with a unique id filename, e.g. based on timestamp + random value). The application could watch a designated directory for these files to pop-up. After processing them, it could just delete them. For that, the application only needs write permission on the directory (so file ownership is not an issue).
If possible, use shell scripts.
I did something similar, i wrote a video surveillance application. The video part is handled by motion (a great FOSS package). The application is a turn-key solution on standardized hardware, used to monitor slot-machine casinos. It serves as a kiosk system locally and is accessible via internet. I wrote all UI code in PHP, the local display is a tightly locked down KDE desktop with a full screen browser defaulting to localhost. I used shell scripts to interact with motion and the OS.
On a second thought:
If you can use self-compiled applications on the device: Write a simple program that returns the value you want and use PHP's exec() or passthru() or system().