read file with Phpass with Codeigniter - codeigniter

i get this error while using Phpass 0.3 on my CI Controller
Message: is_readable() [function.is-readable]: open_basedir restriction in effect. File(/dev/urandom) is not within the allowed path(s): (/home/:/usr/lib/php:/usr/local/lib/php:/tmp)
Filename: phpass-0.3/PasswordHash.php
can someone tell me the problem is?

open_basedir is a directive defined in your php.ini file.
It is set to the lowest directory that you are allowed to access from a PHP script, usually your webroot.
Trying to access a file/directory further down the tree such as in /dev/ will then be dissallowed and you will get the message you have.
You will have to edit your php.ini and set open_basedir to your server root, which is generally a bad thing security-wise as if anyone managed to inject malicious code into your script they would have access to the entire system.
It would be safer to exececute a script (Perl, Python, etc) that lives in your web folder to read /dev/urandom if you really need to.
$output = `/scripts/get_urandom.pl`;
// Process output
Version 1.8 of phpass resolves this issue by suppressing the error:
Changes since revision 1.7: +2 -2 lines:
Prefixed is_readable() with "#" to suppress warning when open_basedir
restriction is in effect.

Related

Set sys_temp_dir in your php.ini

PHP temp directory (C:\Program Files\KMSpico\temp;C:\xampp\php\tmp) does not exist or is not writable to Composer. Set sys_temp_dir in your php.ini
On your system, the PHP function sys_get_temp_dir() returns the string "C:\Program Files\KMSpico\temp;C:\xampp\php\tmp".
This is certainly a misconfiguration as it contains two pathnames concatenated with a semicolon (";"):
C:\Program Files\KMSpico\temp
C:\xampp\php\tmp
The semicolon here is the Windows Path Separator. Composer does not support it, it expects a single pathname.
Check your PHP configuration, this can be controlled with the sys_temp_dir setting.
Having multiple paths there-in looks like a misconfiguration to me, but I'm not using Windows much in the recent decades, so my knowledge is a bit rusty whether this is common or not. For me this really smells like some misconfiguration on your box.
In any case, having multiple paths is not a configuration that Composer supports. Hence you see the error message.
Have you tried to reset it to the default value (empty string)?
Have you recently fiddled with the TMP or TEMP environment parameter(s)?

Joomla "Fatal error: Cannot redeclare jblogerror() in on line 0"

Here is a weird problem i'm facing; after updating Joomla to the latest version, website failed to up load but, as i've made a backup manually from these folders:
administrator
bin
cli
components
includes
layouts
libraries
modules
plugins
yt-assets
and all the root files, after restoring the backup still the website is not loading and just says
"Fatal error: Cannot redeclare jblogerror() in on line 0" !
Any suggestion? Thank you.
Apparently, the version of jBlog you are using is loading its attempting to load its own classes twice.
Let's assume the jBlog developers already fixed it and you carelessly ignored the warning to ensure all your extensions are compatible before updating.
Are you able to access administrator? Simply go there and upgrade jBlog including any modules.
Else, the issue lies within a plugin. In order to access the administrator and perform the update, you will need to manually disable the offending plugin.
A simple way is to rename its folder: start from plugins/system then plugins/content hopefully you'll have spotted it by then. Look into the subfolders of each and spot any that may be relevant to jBlog (or grep through the folder to locate the specific string)
If you have console access, simply run
# grep -rl jblogerror plugins/system
and you should see all the files that include such string, just rename their main plugin folder. But you could also do all this through ftp and guessing.

This page isn't working ERROR 500 Savsoft

I uploaded files from SavsoftQuiz_v5.0 to my web server and configured all the necessary files step by step. Tried running the site on the web and it keeps producing an error:
HTTP ERROR 500 - This Page isn't working.
The error logs generated this file
ERROR - 2020-04-21 22:45:31 --> Severity: error --> Exception:
Session: Configured save path '/var/lib/php/session' is not a
directory, doesn't exist or cannot be created.
/var/www/vhosts/africansurveyors.co.zw/httpdocs/Eduline/system/libraries/Session/drivers/Session_files_driver.php
138
HOW DO I FIX THE PROBLEM?
shan is correct, you need to configure your php session to allow write access or to point to a folder you control that actually exists.
Reading a similar usage from https://codeclimate.com/github/bcit-ci/CodeIgniter/system/libraries/Session/drivers/Session_files_driver.php/source [Line112]
it looks like you can set "session.save_path" value from php.ini. Set this to something you control, maybe it supports relative paths, go find out!
You may find you have other folders incorrectly set or defaults assigned, like your temp folder. Don't be afraid to get familiar with php.ini if you plan to stick with php things, but backup before you make changes!

Call to undefined function mysql_connect [duplicate]

This question already has answers here:
Fatal error: Call to undefined function mysql_connect() in C:\Apache\htdocs\test.php on line 2
(2 answers)
Closed 3 months ago.
I just installed PHP and Apache on my home PC. When I try to call function mysql_connect I get:
fatal error: call to undefined function mysql_connect.
I have loaded php.ini where I have uncommented lines extension=php_mysql.dll and
extension=php_mysqli.dll and changed extension directory to extension_dir = "C:\php\ext" - which is the directory where files php_mysql.dll and php_mysqli.dll are. How can I fix this problem?
Output of phpinfo():
http://jsfiddle.net/MMTwA/
After looking at your phpinfo() output, it appears the mysql extensions are not being loaded. I suspect you might be editing the wrong php.ini file (there might be multiple copies). Make sure you are editing the php file at C:\php\php.ini (also check to make sure there is no second copy in C:\Windows).
Also, you should check your Apache logs for errors (should be in the \logs\ directory in your Apache install.
If you haven't read the below, I would take a look at the comments section, because it seems like a lot of people experience quirks with setting this up. A few commenters offer solutions they used to get it working.
http://php.net/manual/en/install.windows.extensions.php
Another common solution seems to be to copy libmysql.dll and php_mysql.dll from c:\PHP to C:\Windows\System32.
Background about my (similar) problem:
I was asked to fix a PHP project, which made use of short tags. My WAMP server's PHP.ini had short_open_tag = off.
In order to run the project for the first time, I modified this setting to short_open_tag = off.
PROBLEM Surfaced:
Immediately after this change, all my mysql_connect() calls failed. It threw an error
fatal error: call to undefined function mysql_connect.
Solution:
Simply set short_open_tag = off.
My PC is running Windows 7 (Apache 2.2 & PHP 5.2.17 & MySQL 5.0.51a), the syntax in the file "httpd.conf" (C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf) was sensitive to slashes.
You can check if "php.ini" is read from the right directory. Just type in your browser "localhost/index.php". The code of index.php is the following:
<?php
echo phpinfo();
?>
There is the row (not far from the top) called "Loaded Configuration File". So, if there is nothing added, then the problem could be that your "php.ini" is not read, even you uncommented (extension=php_mysql.dll and extension=php_mysqli.dll). So, in order to make it work I did the following step. I needed to change from
PHPIniDir 'c:\PHP\'
to
PHPIniDir 'c:\PHP'
Pay the attention that the last slash disturbed everything!
Now the row "Loaded Configuration File" gets "C:\PHP\php.ini" after refreshing "localhost/index.php" (before I restarted Apache2.2) as well as mysql block is there. MySQL and PHP are working together!
You have probably forgotten to restart apache/wamp/xamp/whatever webserver you use, you need to do that in order to make it work
Check your php.ini, I'm using Apache2.2 + php 5.3. and I had the same problem and after modify the php.ini in order to set the libraries directory of PHP, it worked correctly. The problem is the default extension_dir configuration value.
The default (and WRONG) value for my work enviroment is
; extension_dir="ext"
without any full path and commented with a semicolon.
There are two solution that worked fine for me.
1.- Including this line at php.ini file
extension_dir="X:/[PathToYourPHPDirectory]/ext
Where X: is your drive letter instalation (normally C: or D: )
2.- You can try to simply uncomment, deleting semicolon. Include the next line at php.ini file
extension_dir="ext"
Both ways worked fine for me but choose yours. Don't forget restart Apache before try again.
I hope this help you.
Hi I got this error because I left out the ampersand (&) in
; php.ini
error_reporting = E_ALL & ~E_DEPRECATED
Be sure you edited php.ini in /php folder, I lost all day to detect error and finally I found I edited php.ini in wrong location.
After change our php.ini, make sure to restart Apache web server.
Just for future reference, copying all these extension files to Windows/System or Windows/System32 is unnecessary.
All that is required is a copy of the php.ini file you edit in the PHP dir to copied to the root Windows dir.
phpinfo will clearly explain the below:
Configuration File (php.ini) Path C:\Windows
Logical sense will explain that php wants to load a config located in the Windows dir. :-)
One time I had a problem while using Off instead of off. And also check the pads one more time... The path has to be exact. Also add the following line to your environmental variable.
C:\your-apache-path\bin; C:\your-php-path\bin;C:\your-mysql-path\bin
If you are in Windows, right click My Computer, select properties, and navigate to the Advanced tab... (is Windows 7). Click on Advanced system settings first then select the Advanced tab and then Environmental variables. Select PATH and click on Edit. Make a copy of the string in a .txt file for back up (it might be empty)--- set your environmental variables... Log out and log back in.
Since mysql_connect This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used.
by default xampp does not load it automatically
in your php.ini file you should uncomment
;; extension=php_mysql.dll
to
extension=php_mysql.dll
Then restart your apache you should be fine
This same problem drove me nuts (Windows 10, Apache 2.4, MySql 5.7). For some reason (likely PATH related), the .dlls would not load after uncommenting the correct exension dlls and extension_dir = "ext" in php.ini. After trying numerous things, I simply changed "ext" to use the full directory path. For example. extension_dir = "c:/phpinstall/ext" and it worked.
I think that you should use mysqli_connect instead of mysql_connect

including files without having to specify $_SERVER['DOCUMENT_ROOT']

Before the PHP Version update I used to be able to include files as following without specifying the document root:
<?php include '/absolute/path/to/files/file1.php'; ?>
However I now have to include the same file as following:
<?php include $_SERVER['DOCUMENT_ROOT'].'/absolute/path/to/files/file1.php'; ?>
What php.ini setting could have overridden the former behaviour?
You need the php.ini directive include_path
See: http://us.php.net/manual/en/ini.core.php#ini.include-path
Including an absolute path should be working the same way straight through PHP 5.2.9 (haven't tried 5.3, but this shouldn't change). Since you're specifying an absolute path, the include_path directive has no bearing.
Can you provide some more information? What PHP version, platform, and the error you get back from include would be a great start.
Linux: RHEL 5 PHP: Version PHP 5.2.9 Error Messages I get are: PHP Warning: require(/conf/common.php): failed to open stream: No such file or directory in /var/www/vhosts/DOMAIN/httpdocs/tell-a-friend-fns.php on line 63 PHP Fatal error: require(): Failed opening required '/conf/common.php' (include_path='.:/usr/share/pear:/usr/lib/php:/tmp') in /var/www/vhosts/DOMAIN/httpdocs/tell-a-friend-fns.php on line 63
Okay, it looks like your application is living in /var/www/vhosts/DOMAIN, and you're looking for /conf/common.php, right? I don't know if your file is actually in /conf/ or if it's in /var/www/vhosts/DOMAIN/conf/ (I assume the latter, with the information given). If it's in /conf/, then make sure that your Web server user can read that directory. If not, change your include to /var/www/vhosts/DOMAIN/httpdocs/conf/common.php.
Better yet, you might be able to do include '../conf/common.php, depending on where common.php lives in relation to your main script for the requested page.
Remember that any path given with a leading "/" is absolute in relation to the file system, not the Web server document root. Any path given without a "/" is assumed to be a relative path, relative to your executing script (not the current file). My guess is that prepending $_SERVER['DOCUMENT_ROOT'] to your path is changing the absolute path to a relative path. I have no idea why an absolute path would act as a relative path pre-upgrade, unless you were operating in a jailed environment (common with virtual hosts) which got removed during the upgrade.
I always use something like:
require( dirname( __FILE__ ) . '/../../subdir/somefile.php' );
It gives you a relative path from the current file, but resolves to an absolute path (by using dirname on the current file).

Resources