Archive for the ‘php’ Category

adjust /etc/php.ini (default path)
then /usr/local/psa/bin/php_settings –update-all -> it modifies all websites php.ini according to server /etc/php.ini

# /usr/local/psa/bin/php_settings –help

Usage: php_settings command [options]
Available commands:
–update-all or -u Update per-domain PHP settings of all domains in accordance with the server-wide php.ini file.


create /var/www/vhosts/$DOMAIN$/conf/vhost.conf

content:

<DIRECTORY /var/www/vhosts/$DOMAIN$/httpdocs>

<IfModule sapi_apache2.c>

php_admin_flag engine on

# General settings

php_admin_flag safe_mode off

php_admin_value open_basedir "/var/www/vhosts/$DOMAIN$/:/tmp/"

# Performance settings (not mandatory)

php_admin_value memory_limit 512M

php_admin_value max_execution_time 600

php_admin_value max_input_time 300

php_admin_value post_max_size 60M

php_admin_value upload_max_filesize 60M

# Additional directives

</IfModule>

</DIRECTORY>

<DIRECTORY /var/www/vhosts/$DOMAIN$/httpdocs>

<IfModule mod_php5.c>

php_admin_flag engine on

# General settings

php_admin_flag safe_mode off

php_admin_value open_basedir "/var/www/vhosts/$DOMAIN$/:/tmp/"

# Performance settings

php_admin_value memory_limit 512M

php_admin_value max_execution_time 600

php_admin_value max_input_time 300

php_admin_value post_max_size 60M

php_admin_value upload_max_filesize 60M

# Additional directives

   AddHandler php5-script .hph

   AddType text/html .hph

</IfModule>

</DIRECTORY>

/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain $DOMAIN$



and voila..

Can be done easy with epel yum repo. more info about epel: http://fedoraproject.org/wiki/EPEL
for centos 5:
wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -ivh epel-release-5-4.noarch.rpm

yum install imagemagick php-magickwand php-pecl-imagick
restart apache and done

That’s all.

tested on Horde: 3.1.7

don’t be tricked by these errors in log:
[error] [client ….] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/psa-pear/PEAR.php
the errors can be disabled in /usr/share/psa-horde/config/conf.php

If you get white page [500 error] after login on horde you can try this:
edit files:

/usr/share/psa-horde/imp/lib/IMAP/Client.php line 576
modify     function namespace($additional = array())
with       function plmnamespace($additional = array())
/usr/share/psa-horde/imp/lib/Session.php line 295
modify     $_SESSION['imp']['namespace'] = $imapclient->namespace($user_namespace);
with       $_SESSION['imp']['namespace'] = $imapclient->plmnamespace($user_namespace);

reload the webmail page and logout/login again.

Please let me know if this helps you. Feedback is appreciated.

UPDATE:
modify all this files to get everything working properly

./IMAP/Tree.php:78: $ptr = reset($_SESSION[‘imp’][‘plmnamespace’]);
./IMAP/Tree.php:83: $this->_namespaces = (empty($GLOBALS[‘conf’][‘user’][‘allow_folders’])) ? array() : $_SESSION[‘imp’][‘plmnamespace’];
./IMAP/Tree.php:184: foreach ($_SESSION[‘imp’][‘plmnamespace’] as $val) {
./Folder.php:139: $delimiter = reset($_SESSION[‘imp’][‘plmnamespace’]);
./Folder.php:678: foreach ($_SESSION[‘imp’][‘plmnamespace’] as $val) {
./Session.php:259: $_SESSION[‘imp’][‘plmnamespace’] = $ptr[‘imap_config’][‘plmnamespace’];
./Session.php:265: $_SESSION[‘imp’][‘plmnamespace’] = array();
./Session.php:268: $user_namespace = (isset($ptr[‘plmnamespace’]) && is_array($ptr[‘plmnamespace’])) ? $ptr[‘plmnamespace’] : array();
./Session.php:278: $_SESSION[‘imp’][‘plmnamespace’][$val] = array(‘name’ => $val, ‘delimiter’ => $box[0]->delimiter);
./Session.php:295: $_SESSION[‘imp’][‘plmnamespace’] = $imapclient->plmnamespace($user_namespace);
./Session.php:296: if (!is_array($_SESSION[‘imp’][‘plmnamespace’])) {
./Session.php:318: $_SESSION[‘imp’][‘plmnamespace’] = null;
./IMP.php:1195: reset($_SESSION[‘imp’][‘plmnamespace’]);
./IMP.php:1196: $mailbox = key($_SESSION[‘imp’][‘plmnamespace’]);
./IMP.php:1204: foreach ($_SESSION[‘imp’][‘plmnamespace’] as $key => $val) {
./IMP.php:1211: if ($empty && isset($_SESSION[‘imp’][‘plmnamespace’][”])) {
./IMP.php:1212: $cache[$key][$mailbox] = $_SESSION[‘imp’][‘plmnamespace’][”];
./IMP.php:1236: foreach ($_SESSION[‘imp’][‘plmnamespace’] as $val) {

P.S. If you copy/paste the content to your blog, please quote the source 🙂

Since plesk 9.5, you can choose in plesk how php will run (as apache module will be executed as apache user, as cgi/fastcgi will be executed as domain user/system user)

$ wget -q -O - http://www.atomicorp.com/installers/atomic.sh | sh
wget http://www.atomicrocketturtle.com/RPM-GPG-KEY.art.txt
rpm --import RPM-GPG-KEY.art.txt
$ yum install mod_suphp

edit the /etc/httpd/conf.d/mod_suphp.conf and leave only LoadModule suphp_module modules/mod_suphp.so line
modify /etc/suphp.conf:

$ [global]
logfile=/var/log/suphp.log
loglevel=info
webserver_user=apache
docroot=/var/www/vhosts
allow_file_group_writeable=false
allow_file_others_writeable=false
allow_directory_group_writeable=false
allow_directory_others_writeable=false
check_vhost_docroot=false
errors_to_browser=false
env_path=/bin:/usr/bin
umask=0022
min_uid=500
min_gid=500

[handlers]
x-httpd-php="php:/usr/bin/php-cgi"
x-suphp-cgi="execute:!self"

create file /etc/httpd/conf.d/zzz_suphp.conf with content:

$ <Directory /var/www/vhosts>
<IfModule mod_suphp.c>
AddHandler x-httpd-php .php .php3 .php4 .php5 .phtml
suPHP_AddHandler x-httpd-php
suPHP_Engine on
</IfModule>
</Directory>

With this config you will enable the suPHP only for vhost folder and not for webmail and other folders.

You have also to check the file/folders permissions. If you have files/folders with 777 permission you will get a 500 error. You have to change it to 755 or 644.

You may check first what is the path of sendmail:
whereis sendmail or php -i | grep sendmail
move /usr/sbin/sendmail to something like /usr/sbin/sendmail.or
vi /usr/sbin/sendmail
put the code below:

#!/usr/bin/perl
# use strict;
use Env;
my $date = `date`;
chomp $date;
open (INFO, ">>/var/log/formmail.log") || die "Failed to open file ::$!";
my $uid = $>;
my @info = getpwuid($uid);
if($REMOTE_ADDR) {
print INFO "$date - $REMOTE_ADDR ran $SCRIPT_NAME at $SERVER_NAME \n";
}
else {
print INFO "$date - $PWD - @info\n";
}
my $mailprog = '/usr/sbin/sendmail.or';
foreach (@ARGV) {
$arg="$arg" . " $_";
}
open (MAIL,"|$mailprog $arg") || die "cannot open $mailprog: $!\n";
while (<STDIN> ) {
print MAIL;
}
close (INFO);
close (MAIL);


chmod a+x /usr/sbin/sendmail
touch /var/log/formmail.log
and chmod 777 /var/log/formmail.log

that should be all.

<?php
$password = crypt(‘mypassword’ , ‘d4’);
print $password . ” is the CRYPT_STD_DES version of mypassword<br>”;
$password = crypt(‘mypassword’ , ‘k783d.y1g’);
print $password . ” is the CRYPT_EXT_DES version of mypassword<br>”;
$password = crypt(‘mypassword’ , ‘$1$d4juhy6d$’);
print $password . ” is the CRYPT_MD5 version of mypassword<br>”;
$password = crypt(‘mypassword’ , ‘$2a$07$kiuhgfslerd………..$’);
print $password . ” is the CRYPT_BLOWFISH version of mypassword<br>”;
?>

This will output something like this:

d4/qPbCcJ5tD. is the CRYPT_STD_DES version of mypassword
k7xEagYCDPPSc is the CRYPT_EXT_DES version of mypassword
$1$d4juhy6d$a.jIPYnvne1FWF2V6mGQR0 is the CRYPT_MD5 version of mypassword
$2a$07$kiuhgfslerd………..6k0kSI76CqJ/RWGnSp9MWRDF91gJZfW is the CRYPT_BLOWFISH version of mypassword

<?
$data = array(0, 1, 2, 'three', 4, 5, 'six', 7, 8, 'nine', 10);
$mod1 = preg_grep("/4|5|6/", $data);
$mod2 = preg_grep("/[0-9]/", $data, PREG_GREP_INVERT);
print_r($mod1);
echo "<br>";
print_r($mod2);
?> 

http://php.about.com/od/advancedphp/ss/php_preg.htm

The way to execute PHP on a .html page is to modify your .htaccess file. This file may be hidden, so depending upon your FTP program you may have to modify some settings to see it. Then you just need to add this line for .html:

AddType application/x-httpd-php .html

Or for .htm

AddType application/x-httpd-php .htm

If you only plan on including the PHP on one page, it is better to setup this way:

AddType application/x-httpd-php .html

This code will only make the PHP executable on the yourpage.html file, and not on all of your html pages.

http://lerdorf.com/veracruz.pdf