Any one explain me exec() function is needed for TYPO3?
If yes than describe in which typo3 functionality depends on this function. if i have disable this function then what happening in typo3? which functionality will not work after disable this function...
Thanks...
A single search for "shell_exec" on typo3's source code finds two potential matches :
SpellCheckingController.php, which calls Aspell functions, for spell checking purposes for the htmlArea RTE extension
Scheduler.php calls Unix at and atrm functions
So, these are not vital functionalities, but you may have to disable manually the spell checker for your textareas (As I understand in the documentation).
As for the scheduler, it won't cause any problem if you don't intend to use it.
Depending on which exec function you disable you might loose the possibility to use the mighty tool ImageMagic/GraphicsMagic for resizing and modifying images. It is not vital, but restrict you or your editors in using images.
Related
I tried setting up VS Code for a legacy PHP project, to evaluate it against other IDEs.
My problem is with the suggestions I get, when I press <an object>->Ctrl+Space.
For example I want to get all suggestions (properties and functions) of a certain class. I am in the class and I type:
$this->(Ctrl+Space)
I get a large list of functions and constants, which are things I can use in PHP in general and not the functions and properties of the class I am in. After I installed the PHP Intelephense extension, I get the class methods that I need in my suggestions, but still they are mixed with everything else and hard to find, unless I start typing the first letters of the function I need to access. To show you what I mean, this is what I get, when I type the following within a function of my class:
I don't think this is a matter of extension, because even if I disable all my extensions I still get the whole bunch of suggestions. How can I remove all unnecessary suggestions, or at least give priority to the class specific suggestions and see them on top of the list?
You must disable the vscode built-in PHP Language Features.
Click extensions.
In the search bar type #builtin php.
Click cog icon of PHP Language Features.
Click Disable.
I've been struggling with this for while too ...
You can just disable the basic PHP suggestions by setting php.suggest.basic to false in your settings.json file or use the settings UI at PHP > Suggest: Basic
With Intelephense installed everything works as expected now !
source : https://code.visualstudio.com/docs/languages/php#_disable-builtin-php-support
I have a php project which needs upgrading from php 5.3 to php 5.6(and eventually, to php7), and from what I see in the PHP docs, the /e modifier for preg_replace is deprecated, and is to be removed, and I have to search all of its occurences and remove them(and replace them with something else, such as preg_replace_callback).
The problem is that there are lots of calls to preg_replace(around 2100 calls), and it would take a lot of time to check each of them manually, and I would like to create a script(either a php script or a bash script) which searches for all the preg_replace calls which use the specified modifier. I have searched online, and I found that this should be done either with a regex expression or with tokenizer. I have tried, but I have not managed to create a script which does just that(mainly because I have not really used any of the two functionalities mentioned, and am not proficient in any of them).
I was wondering if there is any easier way to do this, or if anyone could help me in creating a script which searches the entire codebase and outputs the required calls.
Thank you in advance.
You could use your code editor's find and replace:
Do a backup of your code (if you don't use git or something)
Use the Find in Folder ( or similar ) option
Check the Regular Expression (or similar) option when searching
Use a simple regex like preg_replace*?\/e
Replace the occurences one by one
Move your code in PHP 5.6 environment and see if it works.
How to enable code hinting for the user defined functions in SublimeText?
e.g. if I declare a function in my project like this:
function my_func($arg1,$arg2){
// some code
}
and then I type 'my_func' in some other file, then it gives me hint and auto-completes the code for me, as it does for the default php functions like substr() etc.
Is there a way in SublimeText for this that I am not aware of?
Sublime text is a code editor and not an IDE. So don't expect to have IDE features in it. But you can use https://packagecontrol.io/packages/PHPIntel for PHP code completion.
Check out SublimeCodeIntel. You'll need to have Package Control installed first. The plugin is based on Komodo, and supports code completion (and several other features) for many different languages, including PHP. You'll need to customize the configuration for your individual needs, but the settings are pretty well documented, so it shouldn't be too difficult. If you have any issues, search Stack Overflow as there are a number of answers regarding its configuration.
Good luck!
I want to write a simple PHP fiddle for a programming tutorials website
Similar to Code Academy website
Example
Code Academy PHP Fiddle Example
I thought of using Code Mirror as a text editor
But How I could execute the PHP Code that the user write safely ??
I tried to use file_put_contents() and file_get_contents in their editor
And it works :) is it safe !!
I can't use extensions like runkit
because I am on a shared hosting :(
Short answer: You can't. You need a sandbox of some sort, which will take far more systems access than you'll get on shared hosting. You would need to set up your own host with your own sandboxed PHP executables in order to achieve this.
As you have it there, it is absolutely not safe.
I think the safest way is to edit PHP sources and remove the most dangerous functions, compile this and run this new PHP environment from the real PHP.
Parsing the user input and sending to eval is in my opinion a security hole. You wouldn't be able to detect dangerous statements like
$a = 'ma';
$a .= 'il';
{$a}(...);
etc.
The situation is next:
I have php file, which parses a web-page. on that web-page is a phone number and it's digits are mixed with each other. The only way to put each digit on the correct place is to use some JS functions (on the client side). So, when I execute that php file in linux console, it gives me all that I need, except js function's result (no wonder - JavaScript is not a server-side language). So all I see from JS - only a code, that I have written.
The question: can I execute js files via php and how?
Results of a quick google search (terms = javascript engine php)
J4P5 -- not developed since 2005 [BAD](according to its News)
PECL package spidermonkey
a 2008 post by jeresig points to PHPJS but can't see when it was last updated.
I'm sure you'll find many more links on that google search.
Alternatively:
you say that the digits are scrambled and you need to "unscramble" them using js. Can you code that unscrambling logic into a PHP function and just use it? Will sure save you a lot of trouble, but if learning to use js in php is what you're after, then its a whole different story...
Zend tutorial: "Using javascript in PHP with PECL and spidermonkey"?
http://en.wikipedia.org/wiki/Comparison_of_Server-side_JavaScript_solutions
Alternatively, PHP has simple functions for executing other programs and retrieving their output (I used this along with GPG once to create a PHP file manager which could live-encrypt files as you were uploading them and live-decrypt as you were downloading them)
Using those functions along with http://code.google.com/p/v8/ you should be able to interpret any javascript.
Not unless you know someone who's implemented a Javascript engine in PHP.
In other words, probably not.
Without some sort of browser emulation or passing the unparsed js off to a server side implementation of javascript (maybe node.js?), you won't be able to execute it.
However, does the page use the same js function to unscramble the phone number every time? You should be able to read the incorrect digits and shuffle them with PHP.
If you're prepared to do a bit of work building your own JS runtime to work with it, Tim Whitlock has written a javascript tokenizer and parser in pure PHP
node.js is server-side... but full JS :) no PHP in it so I don't it answer your needs...
Anyway, here is an example : a chat in JS both client & server-side : http://chat.nodejs.org/
Plus, not every host allows you to use the v8 engine...
If you have Javascript data objects, and you need to convert them to/from PHP arrays, that's quite easy using PHP's json_encode() and json_decode() functions.
But actually running Javascript code? No. You can't. You might be able to find a JS interpreter written in PHP (a few other answers have pointed a links that may or may not help you here), or more likely execute the JS using a stand-alone JS interpreter on your server which you call out to from PHP. However if the JS code includes references to the browser's DOM (which is highly likely), that's a whole other set of issues which will almost certainly make it impossible.
Given the way you describe the question, I'd say the easiest solution for you would just be to re-implement the JS code as PHP code; it's unlikely that all the work arounds being suggested would be appropriate for what sounds like a fairly simple bit of utility code.