I have just tried enabling php_browscap.ini so that I can use the get_browser function.
However, it seems to display an empty array?
$user_agent = get_browser(null, true);
print_r($user_agent);
In my php.ini file, I have the following:
[browscap]
; http://php.net/browscap
browscap = C:/wamp/bin/php/php5.3.0/extra/php_browscap.ini
I am probably missing something simple?
Update
Output I get:
Array ( [browser_name_regex] => §^.*$§ [browser_name_pattern] => * [browser] => Default Browser [version] => 0 [majorver] => 0 [minorver] => 0 [platform] => unknown [alpha] => [beta] => [win16] => [win32] => [win64] => [frames] => 1 [iframes] => [tables] => 1 [cookies] => [backgroundsounds] => [cdf] => [vbscript] => [javaapplets] => [javascript] => [activexcontrols] => [isbanned] => [ismobiledevice] => [issyndicationreader] => [crawler] => [cssversion] => 0 [supportscss] => [aol] => [aolversion] => 0 )
You could find if there's something else failing using tools like ProcMon. This tool will tell you which files had been accessed, and what was the result. So, you have to open it, highlight the browsercap ini's path, restart the webserver and see if any of this scenarios fits:
File doesn't exist
Permission denied
Finding wrong path
Doesn't appear at all
ProcMon is a Wonderful tool if you're in Windows.
If you find any of those scenarios, and don't know what to do, just edit your question :-)
Good luck!
There are several php.ini files for WAMP. To get to the right one, access it using the WAMP tray icon. That's how I got it to work. As it turns out, in my case it used the one in C:\Apps\wamp\bin\apache\apache2.2.22\bin.
Related
I'm using AlmaLinux 8.4, and I'm trying to install Zend Opcache and verify that it's running.
In Easy Apache, php8 and php80-php-opcache are installed. php -1 shows Zend is not enabled, while php -a does, and 10-opcache.ini is loaded. (I see that CLI is not enabled, but I don't need it.)
Apache and PHP-FPM have been restarted several times.
Is this configuration correct?
How do I determine if Zend Opcode is actually running?
[root}# php -i shows:
Zend OPcache
Opcode Caching => Disabled
Optimization => Disabled
SHM Cache => Enabled
File Cache => Disabled
JIT => On
Startup Failed => Opcode Caching is disabled for CLI
Loaded Configuration File => /opt/cpanel/ea-php80/root/etc/php.ini
Additional .ini files parsed => /opt/cpanel/ea-php80/root/etc/php.d/10-opcache.ini
Core
PHP Version => 8.0.9
zend.assertions => -1 => -1
zend.detect_unicode => On => On
zend.enable_gc => On => On
zend.exception_ignore_args => Off => Off
zend.exception_string_param_max_len => 15 => 15
zend.multibyte => Off => Off
zend.script_encoding => no value => no value
zend.signal_check => Off => Off
The file /opt/cpanel/ea-php80/root/etc/php.d/10-opcache.ini shows
Enable Zend OPcache extension module
zend_extension=opcache.so
; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
;opcache.enable_cli=0
; The OPcache shared memory storage size.
opcache.memory_consumption=128
; The amount of memory for interned strings in Mbytes.
opcache.interned_strings_buffer=8
; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 100000 are allowed.
opcache.max_accelerated_files=4000
php -a shows
php > print_r(opcache_get_configuration());
Array
(
[directives] => Array
(
[opcache.enable] => 1
[opcache.enable_cli] =>
[opcache.use_cwd] => 1
[opcache.validate_timestamps] => 1
[opcache.validate_permission] => 1
[opcache.validate_root] =>
[opcache.dups_fix] =>
[opcache.revalidate_path] =>
[opcache.log_verbosity_level] => 1
[opcache.memory_consumption] => 134217728
[opcache.interned_strings_buffer] => 8
[opcache.max_accelerated_files] => 4000
[opcache.max_wasted_percentage] => 0.05
[opcache.consistency_checks] => 0
[opcache.force_restart_timeout] => 180
[opcache.revalidate_freq] => 2
[opcache.preferred_memory_model] =>
[opcache.blacklist_filename] => /opt/cpanel/ea-php80/root/etc/php.d/opcache*.blacklist
[opcache.max_file_size] => 0
[opcache.error_log] =>
[opcache.protect_memory] =>
[opcache.save_comments] => 1
[opcache.record_warnings] =>
[opcache.enable_file_override] =>
[opcache.optimization_level] => 2147401727
[opcache.lockfile_path] => /tmp
[opcache.file_cache] =>
[opcache.file_cache_only] =>
[opcache.file_cache_consistency_checks] => 1
[opcache.file_update_protection] => 2
[opcache.opt_debug_level] => 0
[opcache.restrict_api] =>
[opcache.huge_code_pages] =>
[opcache.preload] =>
[opcache.preload_user] =>
[opcache.jit] => tracing
[opcache.jit_buffer_size] => 0
[opcache.jit_debug] => 0
[opcache.jit_bisect_limit] => 0
[opcache.jit_blacklist_root_trace] => 16
[opcache.jit_blacklist_side_trace] => 8
[opcache.jit_hot_func] => 127
[opcache.jit_hot_loop] => 64
[opcache.jit_hot_return] => 8
[opcache.jit_hot_side_exit] => 8
[opcache.jit_max_exit_counters] => 8192
[opcache.jit_max_loop_unrolls] => 8
[opcache.jit_max_polymorphic_calls] => 2
[opcache.jit_max_recursive_calls] => 2
[opcache.jit_max_recursive_returns] => 2
[opcache.jit_max_root_traces] => 1024
[opcache.jit_max_side_traces] => 128
[opcache.jit_prof_threshold] => 0
)
[version] => Array
(
[version] => 8.0.9
[opcache_product_name] => Zend OPcache
)
[blacklist] => Array
(
)
)
To determine if the opcache is enabled and working and ensure that the JIT actually works, create a PHP script that's accessible via the browser and look at the output of opcache_get_status().
Example PHP file can be:
var_dump(opcache_get_status());
Example output when it is enabled is:
array(9) {
["opcache_enabled"]=>
bool(true)
...
if the opcache extension is not installed or not enabled it will throw this error:
Fatal error: Uncaught Error: Call to undefined function opcache_get_status()
Another option is that you print out your phpinfo and check for opcache in the output:
<?php phpinfo(); ?>
I'm using Apache/2.4.29 with PHP 7.4.5 as module.
Apache and PHP are configured with lito as user.
Virtualhost configuration with PHP settings:
php_admin_value opcache.enabled 1
php_admin_value opcache.preload /home/lito/www/preload.php
php_admin_value opcache.preload_user lito
phpinfo show opcache configuration:
opcache.enable On
opcache.preload /home/lito/www/preload.php
opcache.preload_user lito
No errors on apache log.
After apache restart opcache_get_status haven't any key related with preload status (preload_statistics) and there are only one script preloaded (current phpinfo.php):
Array
(
[opcache_enabled] => 1
[cache_full] =>
[restart_pending] =>
[restart_in_progress] =>
[memory_usage] => Array
(
[used_memory] => 9168872
[free_memory] => 125047784
[wasted_memory] => 1072
[current_wasted_percentage] => 0.00079870223999023
)
[interned_strings_usage] => Array
(
[buffer_size] => 6291008
[used_memory] => 522888
[free_memory] => 5768120
[number_of_strings] => 10969
)
[opcache_statistics] => Array
(
[num_cached_scripts] => 1
[num_cached_keys] => 1
[max_cached_keys] => 16229
[hits] => 1
[start_time] => 1587378881
[last_restart_time] => 0
[oom_restarts] => 0
[hash_restarts] => 0
[manual_restarts] => 0
[misses] => 3
[blacklist_misses] => 0
[blacklist_miss_ratio] => 0
[opcache_hit_rate] => 25
)
[scripts] => Array
(
[/home/lito/www/phpinfo.php] => Array
(
[full_path] => /home/lito/www/phpinfo.php
[hits] => 0
[memory_consumption] => 1040
[last_used] => Mon Apr 20 12:39:15 2020
[last_used_timestamp] => 1587379155
[timestamp] => 1587378955
)
)
)
Is not available opcache preload on Apache with PHP as module (without a custom php.ini)?
Thanks!
UPDATE: Tested adding preload file on /etc/php/7.4/apache2/php.ini and it works fine.
Similar (for nginx with php-fpm): https://bugs.php.net/bug.php?id=79043#1578412872
As far as I can tell, it looks like preloading is not in effect when configured this way.
Answer from PHP core dev:
yes, as preloading happens during early server startup, enabling it through php_admin_value does not work.
Hi I need to parse the ini file shown below using php, which is basically created using Qt QSettings, I have tried the code here, but seems the INI file are different format there.
Is it possible to parse INI file in below format using PHP ?
[General]
Address=
Email=test#gmail.com
Password=123$
Sync=0
Loggedin=1
[Drives]
1\drive=/
1\free=281
1\size=908
2\drive=/media/New_Volume
2\free=6
2\size=7
3\drive=/media/sdb2
3\free=906
3\size=916
size=2
[Cam]
1\detection=0
1\Area.height=2.4
1\Area.width=9.5
2\detection=0
2\Area.height=2.4
2\Area.width=9.5
3\detection=0
3\Area.height=2.4
3\Area.width=9.5
size=2
Update:
Actually the above ini was working as said in below answer, and my actyual ini contains the $ symbol, that was creating the problem.
[General]
Address=
Email=test#gmail.com
Password=123$
Sync=0
Loggedin=1
[Drives]
1\drive=/
1\free=281
1\size=908
2\drive=/media/New_Volume
2\free=6
2\size=7
3\drive=/media/sdb2
3\free=906
3\size=916
size=2
[Cam]
1\detection=0
1\Area.height=2.4
1\Area.width=9.5
2\detection=0
2\Area.height=2.4
2\Area.width=9.5
3\detection=0
3\Area.height=2.4
3\Area.width=9.5
size=2
And seems I have to escape the $ symbol.
It works just fine, take a look at the php code while the .ini file stays exactly as you have it.
$ini_array = parse_ini_file("settings.ini",true);
print_r($ini_array);
//will output
Array
(
[General] => Array
(
[Address] =>
[Email] => test#gmail.com
[Password] => 123$ // note the $ sign in value here
[Sync] => 0
[Loggedin] => 1
)
[Drives] => Array
(
[1\drive] => /
[1\free] => 281
[1\size] => 908
[2\drive] => /media/New_Volume
[2\free] => 6
[2\size] => 7
[3\drive] => /media/sdb2
[3\free] => 906
[3\size] => 916
[size] => 2
)
[Cam] => Array
(
[1\detection] => 0
[1\Area.height] => 2.4
[1\Area.width] => 9.5
[2\detection] => 0
[2\Area.height] => 2.4
[2\Area.width] => 9.5
[3\detection] => 0
[3\Area.height] => 2.4
[3\Area.width] => 9.5
[size] => 2
)
)
Before saying that its a duplicate please read on, I have done my homework properly :)
I have checked the other posts but nothing helped :(
Here are the things that i have already taken care of:
1. Downloaded updated copy of php_browscap.ini from http://tempdownloads.browserscap.com/ (used the 'use only with PHP' version ofcourse)
2. tried php_browscap.ini,lite_php_browscap.ini and full_php_browscap.ini
3. edited the php.ini file to
[browscap]
;http://php.net/browscap
browscap = "C:\xampp\php\extras\full_php_browscap.ini"
4. confirmed that i have changed the correct php.ini file by checking php_info()
5. and yes removed that ; from ';browscap = .....'
6. restated the xampp server
7. tried checking the any file access error using "Process Monitor"
https://www.dropbox.com/s/loi8p0fkykzcndr/process_monitor.png
But still getting the strange values
Array ( [browser_name_regex] => §^.*$§ [browser_name_pattern] => * [comment] => Default Browser [browser] => Default Browser [version] => 0.0 [majorver] => 0 [minorver] => 0 [platform] => unknown [platform_version] => unknown [platform_description] => unknown [alpha] => [beta] => [win16] => [win32] => [win64] => [frames] => [iframes] => [tables] => [cookies] => [backgroundsounds] => [javascript] => [vbscript] => [javaapplets] => [activexcontrols] => [ismobiledevice] => [issyndicationreader] => [crawler] => [cssversion] => 0 [aolversion] => 0 [device_name] => unknown [device_maker] => unknown [renderingengine_name] => unknown [renderingengine_version] => unknown [renderingengine_description] => unknown )
Please help me, I tried a lot spending hours reading the answers posted here, tried to find a solution on google, saw videos of NewBoston
// Loads the class
require 'path/to/Browscap.php';
// Creates a new Browscap object (loads or creates the cache)
$bc = new Browscap('path/to/the/cache/dir');
// Gets information about the current browser's user agent
$current_browser = $bc->getBrowser();
// Output the result
echo '<pre>'; // some formatting issues ;)
print_r($current_browser);
We are going to obviate the last section under the comment ‘Output the result’ so your code should look like this…
// Loads the class
require 'path/to/Browscap.php';
// Creates a new Browscap object (loads or creates the cache)
$bc = new Browscap('path/to/the/cache/dir');
// Gets information about the current browser's user agent
$current_browser = $bc->getBrowser();
Anyone know anything about troubleshooting a PHP Curl problem? I have been using RollingCurl with great success on my OSX laptop, however when I upload to my Ubuntu server the same code fails to yield a result.
So there is clearly something wrong server side, the error logs are clean. I have no idea what to check... any help? Anyone!?
Thank you so much in advance, Stu
![http://rolling-curl.googlecode.com/svn/trunk/
Ubuntu 12.04 result
Array ( \[url\] => \[content_type\] => \[http_code\] => 0 \[header_size\] => 0 \[request_size\] => 0 \[filetime\] => 0 \[ssl_verify_result\] => 0 \[redirect_count\] => 0 \[total_time\] => 0 \[namelookup_time\] => 0 \[connect_time\] => 0 \[pretransfer_time\] => 0 \[size_upload\] => 0 \[size_download\] => 0 \[speed_download\] => 0 \[speed_upload\] => 0 \[download_content_length\] => -1 \[upload_content_length\] => -1 \[starttransfer_time\] => 0 \[redirect_time\] => 0 \[certinfo\] => Array ( ) \[redirect_url\] => )
Local OSX Leoard result
Array ( \[url\] => http://www.google.co.uk/ \[content_type\] => text/html; charset=ISO-8859-1 \[http_code\] => 200 \[header_size\] => 1535 \[request_size\] => 108 \[filetime\] => -1 \[ssl_verify_result\] => 0 \[redirect_count\] => 1 \[total_time\] => 0.597785 \[namelookup_time\] => 0.033881 \[connect_time\] => 0.070866 \[pretransfer_time\] => 0.070939 \[size_upload\] => 0 \[size_download\] => 43439 \[speed_download\] => 72666 \[speed_upload\] => 0 \[download_content_length\] => 221 \[upload_content_length\] => 0 \[starttransfer_time\] => 0.171418 \[redirect_time\] => 0.147887 )][1]
if (ini_get('safe_mode') == 'Off' || !ini_get('safe_mode')) {
$options[CURLOPT_FOLLOWLOCATION] = 1;
$options[CURLOPT_MAXREDIRS] = 5;
}
Here is the problem... I commented it out to test and BANG.... flys into action. Thank you all for your help.
Check your php.ini configuration file in your ubuntu server. In this article you can see many of the good practices that many people (and now, some packages do) to protect their servers from attacks: http://blog.up-link.ro/php-security-tips-securing-php-by-hardening-php-configuration/
UPDATE.
To make it more clear:
Log in to your ubuntu server as an admin user.
Change to the configuration file's directory
cd /etc/PHP5
Search in the file for allow_url_fopen = Off value by using the following command:
sudo nano php.ini
Change the value to On and press CTRL+X answer "yes" to save the changes and quit nano editor