Finding latest release links on website for C++ Application - php

Basically I have written a game plugin that will allow server admins to update their administration tools from within game rather than having to go download it and install it. The releases are updated regularly, and the beta versions are nightly builds.
I am trying to find a way to grab the links from the website, but I cannot think of anyway to do this off of the top of my head. Was hoping someone here might be able to suggest something that would work.
http://www.sourcemod.net/snapshots.php
Thats the website, basically I am trying to grab the links for the latest stable branch, and latest development branch.

The solution is simple and can be broken down into a few steps:
Fetching the links & files: Use cURL/cURLpp or Poco C++. They are easy but you may spend a few hours to learn :)
Processing/Extracting the links: Use TidyHTML to make sure the HTML is converted to valid XHTML and use XPath to extract the links. Can use libxml2 & libxslt. I'd prefer Qt C++
Fetch the extracted links and save them to pre-defined paths. Boost Filesystem may ease your task with file system.
Note that if I were to do this (well, I've done this before), I'd use only Qt C++ as it provides everything I need. Btw, Qt C++ has a dead simple way to send GET/POST requests & fetch files :) Good luck!
EDIT:
Qt C++ XML also provides CSS-like selectors which avoids you using any other libraries: http://doc.trolltech.com/4.6/qt4-6-intro.html#dom-access-api
In short: Just go for Nokia Qt C++ in all the steps. Download from: http://qt.nokia.com/downloads

you could ask them if they have some sort of web service to call?
i.e. you could request the latest version which would return a revision number, you compare that against your current version, if an update is required you call another web service to request the location of the files to download.

Related

PHP as independent application ( binary, compile, pack, no php on host )

If I would like to distribute PHP application with installer(package system of OS) how should I proceed? I don't want PHP files to be there, just working application, so when I type 'app' into console, it ends up being launching application, without need to install PHP on system(no php installation on host required). I would also like the application to have patch-able byte-code, so it's in parts, loaded when needed and only part needs to be replaced on update.
What I would do now is following:
->Compile PHP with extensions for specific platform.
->Make binary application which launches '/full/php app' when app is launched.
->Pack it in installer in a way, that there would be binary added to path when added, launching specific installation of PHP which is alongside the app with argument of start point->App would be running.
Problem is:
Maybe I don't want my PHP files to be exposed(in application, there will be available source anyway) is there some ready made stuff to do this? Is there some better way than I proposed?
Alternative: Modifying OP Cache to work with "packing" application to deliver byte codes to modified OP Cache which just reads the cache.
My suggestion would be a tiny tool I just finished, for almost exactly the same problem. (Oh yes I tried all the others but they're old and rusty, sometimes they're stuck with 4.x syntax, have no support, have no proper documentation, etc)
So here's RapidEXE:
http://deneskellner.com/sw/rapidexe
In the classical way, it's not a really-real compiler, just a glorified packer, but does exactly what you need: the output exe will be standalone, carrying everything with it and transparently building an ad-hoc runtime environment. Don't worry, it all happens very fast.
It uses PHP 7.2 / Win64 by default but has 5.x too, for XP compatibility.
It's freeware, obviously. (MIT License.)
(Just telling this because I don't want anyone to think I'm advertising or something. I just took a few minutes to read the guidelines about own-product answers and I'm trying to stay within the Code of the Jedi here.)
However...
I would also like the application to have patch-able byte-code, so it's in parts, loaded when needed and only part needs to be replaced on update.
It's easier to recompile the exe. You can extract the payload pieces of course but the source pack is one big zip; there seems to be no real advantage of handling it separately. Recompiling a project is just one command.
Maybe I don't want my PHP files to be exposed(in application, there will be available source anyway)
In this case, the exe contains your source compressed but eventually they get extracted into a temp folder. They're deleted immediately after run but, well, this is no protection whatsoever. Obfuscation seems to be the only viable option.
If something goes wrong, feel free to comment or drop me a line on developer-at-deneskellner-dot-com. (I mean, I just finished it, it's brand new, it may misbehave so consider it something like a beta for now.)
Happy compiling!
PHP doesn't do that natively, but here are a few ideas:
Self-extracting archive
Many archival programs allow you to create a self-extracting archive and some even allow to run a program after extraction. Configure it so that it extracts php.exe and all your code to a temp folder and then runs ir from there; deleting after the script has complete.
Transpilers/compilers
There's the old HPHC which translates PHP code to C++, and its wikipedia age also contains links to other, similar projects. Perhaps you can take advantage of those.
Modified PHP
PHP itself is opensource. You should be able to modify it withot too much difficulty to take the source code from another location, like some resource compiled directly inside the php.exe.
Use Zend Guard tool that compiles and converts the plain-text PHP scripts into a platform-independent binary format known as a 'Zend Intermediate Code' file. These encoded binary files can then be distributed instead of the plain text PHP. Zend Guard loaders are available for Windows and Linux platform that enables PHP to run the scripts encoded by Zend Guard.
Refer to http://www.zend.com/en/products/zend-guard
I would like to add another answer for anyone who might be Googling for answers.
Peach Pie compiler/runtime
There is an alternative method to run (and build apps from) .php source codes, without using the standard php.exe runtime. The solution is based on C#/.NET and is actually able to compile php source files to .NET bytecode.
This allows you to distribute your program without exposing its source code.
You can learn more about the project at:
https://www.peachpie.io/
You've got 3 overlapping questions.
1. Can I create a stand-alone executable from a PHP application?
Answered in this question. TL;DR: yes, but it's tricky, and many of the tools you might use are semi-abandoned.
2. Can I package my executable for distribution on client machines?
Yes, though it depends on how you answer question 1. If you use the .Net compiler, your options are different to the C++ option.
3. Can I protect my source code once I've created the application?
Again, depends on how you answer question 1. Many compilers include an "obfuscator" option which makes it hard to make sense of any information you get from decompiling the app. However, a determined attacker can probably get through that (this is why software piracy is possible).

What does Dropbox use for Revision History? How can I add my own?

One of the neater features of Dropbox is that it keeps previous versions of the files you upload.
Part of our site is a similar file repository (customers upload their files to store them offsite), and we'd like to implement a similar feature.
How does Dropbox manage revisions? Do they use some off the shelve revision software that autocommits each file? Or did they just roll their own solution?
I'm hoping there's a 3rd party library I can use for this as it's not the sort of thing we have time to do from scratch ourselves.
Thanks for any help you guys can provide!
More than likely they used a custom solution. Possible methods you can look at are storing a separate file on filesystem for each version, store a separate file in the database for each version, or calculate the diff for the revised file and store that.
The third option is the best as it uses the least space.
Take a look at xdiff_file_bdiff(), it calculates a binary diff of two files (The old version and the new version). The xdiff library should give you the tools you need to do this. You could also look at using something like git for version control, just automate the process using PHP. You'd probably want to run some benchmarks to see what solution works the fastest.

JSR-223 - Where to find ScriptServlet?

I'm confused as to where exactly I should find com.sun.script.http.ScriptServlet that I've seen in numerous samples across the web.
Is JSR-223 included in JDK 1.6? I've seen people talk about a reference implementation, but the only working link on Oracle's site doesn't seem to include such a class. My non-local environment also uses OpenJDK, which I doubt would have any Sun implementation of JSR-223 anyway! In this case where can I get it from? I'm not even sure what 'it' is in this scenario :/
I want to be able to use PHP as a view technology, invoked from a Servlet. I gather JSR-223 was designed with this sort fo usage in mind, but I'm struggling to figure out
Edit
One guide in particular (http://acet.rdg.ac.uk/projects/vre/jsr223inst.php) mentions invocation of PHP via JNI, which sounds ideal. If there's something in existence as part of the final spec that'd allow me to do this via Servlet, I'd be a very happy bunny.
It's available here. Below is an extract of relevance:
Previously, Ludo and Arun described how to run PHP 5 on GlassFish using Quercus, see here and here. However, it is also possible to invoke the native PHP engine on Glassfish, using jsr223 and a PHP bridge. The following steps should work on Sparc Solaris 10.
Download script.jar and drop it into <glassfish>/lib.
Download libphp5-5.0.1-sparc-S2.so, save it as libphp5.so and drop it into <glassfish>/lib.
Download phptest.war and deploy in Glassfish.
Run the PHP on http://localhost:8080/phptest/hello.php.
The class you mentioned is contained in the script.jar file.
There's Quercus, Caucho's Java reimplementation of PHP in Java, quite easy to package as a WAR. JSR223 is included in Java 6, but the only script engine it's shipped with is Rhino, Mozilla's JavaScript interpreter. There are a number of JSR-223 compatible script engines available, check out the repository. Instructions on how to integrate Quercus in eg Glassfish can be found on Arun Gupta's blog.

Linux-based MS Office thumbnail generation

I've been taken onboard to work on a PHP-based web application. One part of the application generates thumbnail images for MS Office documents on demand, and it uses MS Office + the VeryPDF docprint utility to do this. Because of this one requirement, the system is running on Windows Server 2003 + IIS.
I would prefer to have the system running on a Linux server, rather than MS, as I have far more experience in administering Linux systems than Windows and we have no other in-house technical staff.
Does anyone know a way to handle the document conversion using native Linux software? I would love something PHP native, but am willing to look outside that if necessary.
I have never done anything like this, so I'm just throwing an idea off the top of my head.
Have you thought about utilizing Open Office's capabilities to create thumbnail images? I know OO saves thumbnail images within a created document, so all you need to do is extract the image to display it. (This is demonstrated on the Ubuntu forums.) You could always do something sort of "hackish" where you use run a file through OpenOffice and extract the image to display a small thumbnail.
Again, I have no idea how well this will work, but it may be worth a shot.
To anyone else who comes across this, I have ended up going with the newer version of jodconverter. The sample code includes a basic web page that can be POSTed to using something like Pear's HTTP_Request2. A sample class (by yours truly) which uses this is mentioned in the comments in jodconverter's group on google code.

Find PHP Orphan Page

I've inherited a PHP application that has "versions" of pages (viewacct.php, viewacct2.php, viewacct_rcw.php, etc). I want to discover which of these pages are called from other pages in the application and which are not. Is there a tool available that will help with that?
Using whatever tools you would like (Find/Grep/Sed on Linux, I use Visual Studio on windows), it is just a matter of crawling your source tree for references of the filenames in each file.
Similar to FlySwat's answer: any good text editor or IDE with multi-file search should be able to help you find the orphan pages. On Mac OS X I would suggest TextWrangler(free), TextMate($), or BBEdit($$). I've had good success with each of these tools, but your mileage may vary.
If you wish to find out what pages are called by other pages, you need to look at where stuff is being called. Obviously in php code, you can only reference other files via includes or requires and the singular versions of those functions.
So if I were you I would grep your code for include and then require and attempt to make some kind of map showing what is calling what. Eventually you should end up with a pretty clear map of how the php files talk to each other. Then you will need to work out how the various points of the application talk to each other from there via HTML/AJAX etc.
Good luck. I have done it before, it takes a while, but you'll get there, just make sure you document what you find out.
You may want to try out nWire for PHP.
nWire for PHP is an innovative Eclipse plugin (works with Eclipse PDT & Zend Studio 7) which accelerates PHP development by helping developers navigate through their code and better understand the architecture of their application. nWire offers unique tools for real time code visualization, navigation and search.
nWire analyzes all the components and associations in your project. While opening a file you can immediately see where (and if) it is being used.

Categories