I have an issue with accessing an HTML file in an SVN repository. Its contents are displayed as plain text.
What I would like to do is to link to that always up-to-date file from an external website, but I'd like the HTML file to simply launch in the browser (it's a TiddlyWiki file, rather unreadable for human beings in raw text form).
My idea is to simply grab the latest revision of the file and copy it over to my server so that it's accessible as a normal HTML file. Is there a way to easily do that using a PHP script? If there are more than one way, what would you recommend?
If it helps to know it, my server does not have SVN and I have no possibility to install it (it's a shared host).
Check if the Subversion module is available on your server. If that's the case, you can easily create some script that connects to the SVN server and gets the newest file.
If you don't have that module, I can think of two possibilities:
If your SVN server has some kind of web interface, you could simply do a HTML download from the web interface. Depending on the kind of web interface, you might need to extract the file's source out first.
You can also add a postcommit hook to the SVN server that uploads the file to your website; but given that this requires you to change the SVN server's configuration and also puts a direct connection to your website, it might not be what you want.
Have you looked at the SVN extension for PHP?
Related
I have been tasked with changing the code in a block in drupal. When I go to the block (by clicking "configure"), it shows:
Block body:
<?php include('sites/all/contemplates/code-file.php') ?>
How do I edit that file code-file.php from within the Drupal interface?
You can't directly edit executable php files from within your Drupal installation, nor should you or want anyone to be able to. The security implications of uploading executable php files/code to the server via the ui are worrisome.
You should obtain a copy of file, modify it as needed and upload it to your installation via ssh or ftp. Also, using Git makes deployments pretty straightforward.
With all that being said, Drupal core comes with a php filter module that allows you to embed php code that gets executed in text fields. But this isn't considered a good practice anymore either.
I have an idea that will make all Linux servers running PHP more secure.
I want to configure php.ini File Uploads to scan any new file upload with ClamAV's clamscan.
Is it possible? How should I configure it?
While there are libraries for interacting with ClamAV within PHP scripts, there is no way to automatically scan all uploaded files automatically.
Mainly, due to flexibility. For example, if you run a security website to track various viruses and store a copy of each, ClamAV would get to them during the upload, rendering your website useless. The better approach would be to do this in the client code, and use one of the libraries in the link above to perform scanning.
Having said that, I don't believe this is something that's impossible to achieve. You can write a PHP extension that hooks into fileuploads to automatically run ClamAV on uploaded files.
im trying to implement on my site a system who let the user download a file that have to be change before the download.
I have a master file (a .exe program), that inside have a variable who has to be change for every different user.
The most simple solution is to change a variable inside a xml file every time the user want his personalized exe and then make the exe file to read the external file. BUT i dont want the user to download more than one file.
Is this possible? using php can i change a parametter inside a compiled program? Thanks for any help and suggestions!
If you really really know what you're doing and you know exactly the bits that need to be flipped inside the file, then yes, it's possible to modify the .exe file with PHP. Otherwise you have to make changes to the source or other files the .exe is built with and compile the program on the server before sending it to the user.
In theory it's certainly possible (PHP is turing complete), but as stated in other answers it will be hardly worth the hassle (considering the fact that you have to ask whether it is possible shows you'd have to investigate at last for days into the standard exe-format).
I'd recommend one of the following:
1) Zip the program with the configuration file; either use a separate launcher (e.g. Java [a JAR is a ZIP file]) or add a configuration file that is read by the program itself. There is a number of PHP libraries for generating ZIP files.
2) compile the program with the changed source on the server itself; however this can also become quite complicated depending on your server configuration and the programming environment you use. If you have never administered a virtual server I would not even slightly recommend that as an option.
3) If you can assume that the user got somewhat stable Internet access you might also consider to let hir download a standard executable, where additional configuration will be downloaded later on by the program itself (e.g. by transmitting the username to the server). However this creates dependencies you might want to avoid (your user probably can't use it on machines without Internet access and you should assert that your server is up most of the time).
While it's probably possible, I doubt it's worth the hassle. Unless you're trying to fight piracy or something. Why don't you just serve the user a custom .zip file with the .exe and a config .xml?
[edit after OP commented]
I presume what you're trying to edit is the facebook ID/username? Well, try to compile the base file with some unique string like "THISNEEDSTOBEREPLACED", then use some binary safe function to replace it. Though remember things can and will get tricky if the string lengths don't match.
The self-extracting executable that I'm attempting to develop is an installer. An end-user will visit a site, then they will be prompted to register on the site and a download will be provided to them. That download is the self-extracting executable that will install the software on the end-user's computer along with a config file that will have the user's unique id in it. The software is a Windows Service so it will not be able to simply ask the user their username and password.
To be able to insert the registered user's unique id into the installer, I would have to generate the installer on the fly. After researching and using my own experience, I decided that a self-extracting executable would be the best option. The question I have now is how can I generate one using PHP? After researching this problem, I found that the most common solution was to install a executable that could create self-extracting executables on the server machine and then invoke it from PHP. However, executing a executable is not possible with my web host, so this is not a viable solution.
However, executing a executable is not possible with my web host, so this is not a viable solution.
I think in that case, you will need to switch to a web host that lets you do this (or rent a dedicated or virtual server). You can create ZIP files from within PHP when the necessary libraries are installed, but that is about it. Producing Self-extracting executables is not on the menu.
If that is not an option, you would have to find a way to pre-produce the self-extracting executable and inject the user ID into it afterwards. That is surely possible, but I expect you would have to build a custom self-extractor for this.
A self-extracting archive is just an extractor with archive data appended. The extractor program opens itself, finds the offset of the data and extracts. There might be a trailer record to help find the offset.
You can append files easily in PHP: both an archive with your program and the user data. But you need to write a custom extractor that will be aware of this format.
I'm not sure this is possible.. The most you could do is use PHP to dynamically grab the files required surely?
Anyway, perhaps your application could access the internet to grab the files it needs periodically?
Or, you could reference an external PHP file in your program like /data.php?userid=1222&token=9999 which should be fairly secure.
Often, when I am developing in PHP, I want to see minor changes instantaneously. This requires me to either FTP to a web server and then refresh, or use a localhost server, both of which(as I understand) are essentially the same thing.
What I would like to know is, is there an IDE or other way to parse PHP output in a dynamic fashion? I guess what I am thinking of is the WYSIWYG pane in some editors able to display code real-time.
I understand the client-server paradigm, but would rather not have to upload the same file 40 times when making changes/error handling/etc.
You can always just save your files inside your localhost folder. Tools like xampp make running a php server effortless. Open the file in a browser, and whenever you make changes they will instantly be visible without having to copy the files around.
I've heard that ActiveState's Komodo is IDE for php behaving more-less the way you described (at least it has dynamic syntax check, so it has to parse the script locally).
Try Komodo Website.
You should setup your IDE to edit the ftp files in place. I use Edit Plus although I am sure others will do the same thing. In this mode, you open the files in the ftp directory browser (identical to the local one) and when you save, it is automatically uploaded to the server. You can also set it up to save the file locally in a backup folder since it sounds like you aren't using source control. You then set it up so when you CTRL+B, the remote file will open a browser inside the editor (Look under project settings for the root paths).
And yes, while the localhost webserver can be similar, there will be some incompatibilities you will have to overcome, especially if you are running windows and your host is a unix variant. For example: money_format() for one doesn't exist on windows, but is very usefull under linux. Also the configurations will be different even if the OS's are the same.
Good Luck!
This probably doesn't come up very often because it's so easy to install a local web server. What is your OS?
Also if your remote web server is accessible by SSH you could learn a screen oriented text-editor (such as the VI editor) and edit the source files on the server.
I feel the same way, but get around it easily by using an editor/IDE with FTP support. Configure your account, and then edit files locally, but the editor/IDE pushes them to the server when you save them. Notepad++ and PSPad both do this on Windows, and I use Gedit (default Gnome text editor) when on Fedora. A Google search for "FTP text editor" or "FTP IDE" might serve you well.
You could use the PHP command line, but that displays its output in plain text. You could take that output, save it as an HTML file, and display it with a browser, but I'd think that's more work than just setting up a local web server.
Aptana's PHP plugin has a built-in PHP server, so that's probably close enough to what you want, although I've never used it so I can't directly say anything about it.
I may be mistaken, but it seems like you want to see changes without having to restore/maximize browser and clicking 'refresh'. So in other words, you want to see results without the inconvenience of having to maximize browser, clicking refresh, the minimizing it to get back to the editor.
As far as i know, there is no IDE that will show PHP code dynamically in real time.
What you may want to do is, if you can, bind it so when you save a document, it automatically loads up a browser and refreshes the page for you.
Any IDE should notify you of syntax errors (normally with the wavy red underline), which will cut down on a lot of FTP-ing just to find you missed a semicolon.
Even though you say you don't want to use localhost, I would suggest using something like WampServer. The best thing about the latest version is you can install different PHP, MySQL and Apache "modules" and switch between them to mimic any server configuration. For example, "Apache 1.3, PHP 4.2" or "Apache 2, PHP 5.3" etc.