How to call the new command SVNRDUMP (Subversion 1.7) through PHP? - php

I have a PHP client and want to communicate with Subversion server using cURL & WebDav. Please guide me how to write PHP code to do something like svnrdump tool offers?

I suggest you use the SVN library that comes with PHP. All the svndump tool does is to just get each individual changeset and apply it to a new repository, so you'd probably want to use svn_repos_create, then use svn_log to find the number of changesets to download, then a combination of svn_checkout on the remote repository and svn_checkin to apply the changeset to your new repository, followed by duplicating the message.
Edit: There is also a method called svn_repos_hotcopy which may do all of the above. Unfortunately, there is no documentation at all. My guess is that this maps to the c function in SVN, and you can view the source code to see if this would help you (my guess is yes, assuming the PHP call works).

Related

How can I use a PHP module in my Python Google Apps Engine

I'm writing a website using Google Apps Engine Python, and a friend has written some code that he has kindly shared with me that I want to use that's written in PHP. Basically it draws diagrams given some code, and should save an image for it if it doesn't exist.
I've got that code stored in my database in a variable called Diagram_Code, and I want the diagram to render on the page. I'm using jinja to do my templating. I expect I'll have two directories somehow, one with the code in it, and another one with the saved diagrams which are an md5(Diagram_Code).jpg.
I've looked at the documentation for the app.yaml, but I don't understand how I should include it there, if I should.
I'm expecting my python might look something like this:
if not "/diagrams",md5(Diagram_Code),".jpg": #Check if diagram exists already
FUNCTION_TO_USE_PHP(Diagram_Code) #Make diagram with some function
img_url="/diagrams/",md5(Diagram_Code),".jpg"
How should I include it in my app.yaml, and how do I call it in my Python code if this is possible? and if not, what might be the best solution to be able to use what is in the PHP?
You need to use the modules feature, more documentation can be found here.
Basically you deploy a PHP module along side your Python application. You use URLFetch from your python code to make a request to the PHP module to render out whatever it is that you want.
See this on how to do the communication between modules.

How to ask Jenkins detect restricted words in source code and fail build?

I have Jenkins CI.
Source code is PHP.
Jenkins grabs every 5 minutes source code from GIT.
How to configure to scan source code for resticted words:
sqlsrv_
mssql_
I need it to monitor another developers to avoid using deprecated functions in code.
What you need is a static code analysis tool for PHP. Then you need to configure Jenkins to launch that tool.
There are tons available.
Here is a question listing many static code analysis tools for PHP:
Is there a static code analyzer [like Lint] for PHP files?
Here is a question about linking one of those (PHP Code Sniffer) with Jenkins:
Using Jenkins and Php Code Sniffer
I would suggest you define Sniffs (Custom based sniffs) and those can grab The mentioned words whenever they appear. You can then make your build fail or display error message accordingly.
I have been able to create my own Sniffs after seeing how Sniffs are developed in:
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
Hope this helps.

Converting WSDL to PHP source code

A third party provided a WSDL specification, through which I'm going to transfer data to a remote application using SOAP.
I'd like to convert all declared types, constants and method signatures to corresponding classy PHP source code.
Today, I gave WsdlToPhp a try. As far as I figured out, this converter doesn't convert any detail. Furthermore, the documentation has a few rough edges... Maybe a better converter exists.
Q: Could someone propose a stable WSDL to PHP converter?
Please note, that I need a converter to be run offline on a development machine. The WSDL specification isn't publicly available. Therefore, I'm not able to upload the WSDL to a remote converter service.
I used Wsdl2phpgenerator recently. It was pretty easy to use and the generated code has not let me down yet.
I think i done it once, use the pear wsdl lib
http://pear.php.net/reference/SOAP-0.9.4/SOAP/SOAP_WSDL.html#methodgenerateProxyCode

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.

Generate SNMP traps with PHP

I'm desperately searching for a way to generate SNMP traps from PHP. I know the build in methods to use snmpget but I was not able to figure out how to send SNMP traps.
Does anybody know a class / code snippet for it? Searching the web did not bring up anything other than using exec to call cli tools which is definately no option for me.
I suspect that it would be neccessary to use socket_create and corresponding functionality to generate the UDP package manually...
As far as I know, there is no native way for generating traps/informs with php. Even the SNMP extension only permits get and set requests. So the only (quick) way to accomplish this is to call an external tool like net-snmp. The proper command line would be something like
snmptrap -v 1 -c public manager enterprises.spider test-hub 3 0 '' interfaces.iftable.ifentry.ifindex.1 i 1
will send a generic linkUp trap to manager, for interface 1 (taken from the manpage). To execute this from php the net-snmp binaries should be on the path of the system and you could either call exec, shell_exec or proc_open.
Obvisouly you also can send the trap by yourself by encoding it as raw byte array and sending it over an UDP socket, but then you had to implement a BER encoder and a SNMP packet encoder all by yourself which I don't recommend. For your reference, you would need those informations:
Basic Encoding Rules
ASN.1
and some further links found
here
There are no core SNMP trap libraries. Or even any core libraries that will help you package an SNMP udp packet. I did however find this abandoned project. http://code.google.com/p/php-snmp/ which provides most of what you would need to send a simple trap.
A little more active but a lot more complex seems to be http://www.activexperts.com/network-component/howto/snmpts/php/
For anybody searching for such a library these days (in 2019), I found https://github.com/FreeDSx/SNMP which supports sending SNMPv1 and SNMPv2 traps (including inform requests).
I know this question is old, but I just came across it via Google, and thought to update it according to my findings in case someone else also lands here.
As Jek answered, using net-snmp is the best solution.
Although the original post said that he didn't want to use any external components, consider you can now add net-snmp though apt-get (look up package php-snmp) for many Linux distro's, and I'm sure installing on Windows will be equally easy.
The great benefit of using it, is as of PHP 5.3.3, PHP inherintly has built-in interface functions to use SNMP, so that you don't have to use exec, shell_exec or proc_open. Everything can be done in a PHP environment.
See http://php.net/manual/en/book.snmp.php

Categories