Category Archives: PHP

PHP

date_default_timezone_set for php5 date() fixation

Recent upgrade to php5 in appserv make me confuse when my friend ask me about this code :

print date(‘d-M-Y H:i:s’);

hour isn’t accurate

after googling I found about date_default_timezone_set

for full list of supported zone time see this link

http://www.php.net/manual/en/timezones.php

edit  the code into

date_default_timezone_set( "Asia/Jakarta" );

// date.timezone = "timezone_here"

print date(‘d-M-Y H:i:s’);

work well icon smile date default timezone set for php5 date() fixation

PHP Unix

Install gd support in php without xorg

Recent upgrade to php 5.2.3 require to install gd support too but it always need xorg. Here’s a lttle note on how to add gd support in php5 ports in freebsd without xorg.

1. Checking installed php extension

proxy# pkg_info | grep php5
php5-5.2.3          PHP Scripting Language (Apache Module and CLI)
php5-bz2-5.2.3      The bz2 shared extension for php
php5-ctype-5.2.3    The ctype shared extension for php
php5-curl-5.2.3     The curl shared extension for php
php5-dom-5.2.3      The dom shared extension for php
php5-ftp-5.2.3      The ftp shared extension for php
php5-iconv-5.2.3    The iconv shared extension for php
php5-imap-5.2.3     The imap shared extension for php
php5-pcre-5.2.3     The pcre shared extension for php
php5-simplexml-5.2.3 The simplexml shared extension for php
php5-spl-5.2.3      The spl shared extension for php

2. Find php5-gd and install it.

proxy# whereis php5-gd
php5-gd: /usr/ports/graphics/php5-gd
proxy# cd /usr/ports/graphics/php5-gd && make clean
===>  Cleaning for php5-gd-5.2.3

proxy# cd /usr/ports/graphics/php5-gd && make install

===>  Vulnerability check disabled, database not found
===>  Found saved configuration for php5-gd-5.2.3
===>  Extracting for php5-gd-5.2.3
=> MD5 Checksum OK for php-5.2.3.tar.bz2.
=> SHA256 Checksum OK for php-5.2.3.tar.bz2.
===>  Patching for php5-gd-5.2.3
===>  Applying FreeBSD patches for php5-gd-5.2.3
===>   php5-gd-5.2.3 depends on executable in : phpize – found
===>   php5-gd-5.2.3 depends on file: /usr/local/bin/autoconf259 – found
===>   php5-gd-5.2.3 depends on shared library: freetype.9 – not found
===>    Verifying install for freetype.9 in /usr/ports/print/freetype2

wow, alot of things it will installed and tend to install xorg icon sad Install gd support in php without xorg

read more »

PHP

php 5.2.3 upgrade more issue

Warning: session_save_path() [
href="function.session-save-path">function.session-save-path
]:
open_basedir restriction in effect.

with error reporting set, blank page won’t give anything icon sad php 5.2.3 upgrade more issue

A little work need to be done since session not working properly after upgrade php from php 4.4.7 to php 5.2.3.

After doing install and uninstall php5 ports in freebsd 6.2 box. I can see that error.

Googling more to find some clue, I have one plus solution.

The idea is overwrite session_path

just make sure these lines exist in vhost directive :

php_admin_value open_basedir  /home/student

php_value session.save_path /home/student/session

make sure session in /home/student/session exist or make symlink to a directory.

It works now icon smile php 5.2.3 upgrade more issue

PHP Unix

Upgrading to php5

Recent announcement from php.net about end support for php4 make me thinking about upgrading to php5.

All server already use latest php4 version php 4.4.7 with mysql support (4.0.27) and apache1.37

Upgrading start from student server :

1. Uninstall all related php4 ports

2. Install php5 ports

kongja# cd /usr/ports/lang/php5 && make clean
===>  Cleaning for apache-1.3.37_4
===>  Cleaning for php5-5.2.3
kongja# cd /usr/ports/lang/php5 && make install
===>  php5-5.2.3 : Your apache does not support DSO modules.
*** Error code 1

Stop in /data3/ports/lang/php5.
read more »

PHP

PHP 4 end of life announcement

From php.net

"Today it is exactly three years ago since PHP 5 has been released. In those three years it has seen many improvements over PHP 4. PHP 5 is fast, stable & production-ready and as PHP 6 is on the way, PHP 4 will be discontinued. The PHP development team hereby announces that support for PHP 4 will continue until the end of this year only. After 2007-12-31 there will be no more releases of PHP 4.4. We will continue to make critical security fixes available on a case-by-case basis until 2008-08-08. Please use the rest of this year to make your application suitable to run on PHP 5. For documentation on migration for PHP 4 to PHP 5, we would like to point you to our migration guide. There is additional information available in the PHP 5.0 to PHP 5.1 and PHP 5.1 to PHP 5.2 migration guides as well.

For documentation on migration for PHP 4 to PHP 5, we would like to point you to our migration guide. There is additional information available in the PHP 5.0 to PHP 5.1 and PHP 5.1 to PHP 5.2 migration guides as well."

Wow, seem that  php5 campaign get full support

it’s also make zend framework full acceleration since it’s only run in php5 not like codeigniter that run on php4 and php5.

OK, php5 I’m coming icon smile PHP 4 end of life announcement

 

PHP

Running php5 and php4 in single machine using wampserver

In previous post I explain about install wampserver. This step only install php5 not php4, to add php4 support in wampserver php4 add on must installed first.

Here’s sthe steps :

1. Double click php4 add-on installer

 Running php5 and php4 in single machine using wampserver

2. Choose destination folder, in previous step I choose C

read more »

PHP Software

Step by step install wamp in windows xp

With recent progress of php5 campaign and minimum windows xp deployment I think I should upgrade my appserv to wampserver mode.

Wampserver can use dual php mode, php5 by default with php4 as addon.

Latest release :

WAMP5 1.7.2 with PHP 5.2.3 and MySQL 5.0.41

PHP4.4.7 ADD-ON for WAMP5 1.7.2

Latest release can be download here

I download WAMP5 1.7.2 with addon php4

 Step by step install wamp in windows xp

Here’s the the installation steps :

read more »

Blog PHP

Hello dosh dosh, problogger, johnchow, google etc

I often visit to some blog and give a comment and back visit come back for 1 or 2 icon smile Hello dosh dosh, problogger, johnchow, google etc .

One of my friend ask :

"I want to add php snippet in my wordpress, is it possible?"

Yes, I just modify my cwlis wordpress theme (index.php) file and integrate rthanks plugin inside index.php for say hi to visitor from reference site/blog like google, problogger, johnchow etc.

More fun but might be not suitable for person who like to change wordpress theme easily since they must edit index.php each time they change template icon smile Hello dosh dosh, problogger, johnchow, google etc

The point I wanna tell is adding manual php code also possible to other engine like joomla. Make sure You know where to put it and doing little trial error to make it really  work icon wink Hello dosh dosh, problogger, johnchow, google etc

For example :

I add this code :

<?php get_header(); ?>

             <?

        if (preg_match(‘/^http:\/\/(\w+\.)?(google|johnchow|yahoo|

blogspot|doshdosh|problogger|cosaaranda|vavai)\./’,$_SERVER['HTTP_REFERER']) == 1)

{

 // get host name from URL

preg_match(‘@^(?:http://)?([^/]+)@i’,$_SERVER['HTTP_REFERER'], $matches);

$host = $matches[1];



 // get last two segments of host name

preg_match(‘/[^.]+\.[^.]+$/’, $host, $matches);

 //echo "domain name is: {$matches[0]}\n";





echo "<p style=’border:thin dotted black; padding:3mm;’>Welcome <b>{$matches[0]}</b> user . Thanks for visiting my Blog icon smile Hello dosh dosh, problogger, johnchow, google etc </p>";

?>



<?

}

?>

in index.php before this :

<div id="leftside">
    <?php if (have_posts()) : ?>
       
        <?php while (have_posts()) : the_post(); ?>

same output with wordpress plugin.

Just change "google|johnchow|yahoo|blogspot|doshdosh|problogger|cosaaranda|vavai" into some domain that often send visitor to your site/blog.

For some level by write this code directly to php code of engine will decrease load of plugin call icon smile Hello dosh dosh, problogger, johnchow, google etc

 

PHP

disable php function in vhost or multiple user environment

Providing php access to many user require patience plus security aware.

People can damage server with some php function like system, passthru etc.

php provide php.ini file, this file needed to disable some dangerous function.

some option for disable php function are :

system, exec, shell_exec, passthru, set_time_limit, error_log, ini_alter, dl, pfsockopen, openlog, syslog, readlink, symlink, link, leak, fsockopen, popen, escapeshellcmd, apache_child_terminate apache_get_modules, apache_get_version, apache_getenv, apache_note,apache_setenv,virtual

after get this information php must know about these fucntion by editing php.ini files. This file located in C:\windows (in my win xp)

 disable php function in vhost or multiple user environment

Double click to open, click edit -> find enter  "disable_function"

 disable php function in vhost or multiple user environment

Before edit, the line will like this

 disable php function in vhost or multiple user environment

read more »

Blog PHP

rthanks, wp-plugin for say thanks

In last few days after testing stumbleupon effect I see very good result, almost everyday stats log get visitor from stumbleupon. Other socialbookmark like digg also included, netscape etc.

 rthanks,  wp plugin for say thanks

Google analytics also give interesting result, direct access very small while two other source come into major contributor :

  • Search Engines
  • Referring sites

 rthanks,  wp plugin for say thanks

I also see some question about how to increase rss subscriber :

read more »

Blog PHP

Other method to reduce adsense ads blindness

I just found a few post around ads blindness.

What exactly ads blindness?

From this post :

"Ads Blindness means the Adsense Ads are well-blend on the site and makes it not attractive and not easily observed. This is a bad way to make more from AdSense. You need to blend the AdSense Ads and you need to make it look appealing to get more clicks."

ouch, I don’t know that icon smile Other method to reduce adsense ads blindness

There’s some solution on that post and a few post around this stuff :

I have implement simple method that might be already deploy in other blog. Might useful for some of you to reduce ad blindness icon smile Other method to reduce adsense ads blindness

Watch these pictures :

1. Adsense ads located in the right

 Other method to reduce adsense ads blindness

read more »