Archive for the Category »PHP «

PHP Parse error: syntax error, unexpected T_STRING?

If you receive following error in the error logs

” PHP Parse error: syntax error, unexpected T_STRING”
Then you can add following line in the .htaccess file

php_flag short_open_tag X

Or

If your server is SuExec enabled then you can use following code in php.ini file
short_open_tag = X

How to access Awstats From Outside the control panel

How to access Awstats From Outside the control panel

Accessing Awstats from outside the control panel is easy.

Step 1.
Download awstats from http://awstats.sourceforge.net

Step 2.
Uncompress awstats-5.6.tgz

Step 3.
Copy the contents of the uncompressed cgi-bin folder from your hard drive to the user cgi-bin directory (this includes awstats.pl, awstats.model.conf, and the lang, lib and plugins sub-directories).

Step 4.
If necessary (should not be needed with most setups), edit the first (top-most) line of awstats.pl file that is
#!/usr/bin/perl
to reflect the path were your Perl interpreter is installed. Default value works for most of Unix OS, but it also might be #!/usr/local/bin/perl

Step 5.
Move AWStats icon sub-directories and its content into a directory readable by your web server, for example /home/users/public_html/icons

Step 6.
Copy awstats.model.conf file into a new file named awstats.myvirtualhostname.conf. This new file must be stored in /home/user/public_html/cgi-bin.

Step 7.
Edit this new config file with your own setup :
- Change LogFile value with full path of your web server log file (The path is: LogFile=”/usr/local/apache/domlogs/domain.com”).
- Check if LogFormat has the value “1″ (it means “NCSA apache combined/ELF/XLF log format”).
- Change DirIcons parameter to reflect relative path of icon directory. (DirIcons=”/icons”)
- Edit SiteDomain parameter with the main domain name or the intranet web server name used to reach the web site to analyze (Example: www.mydomain.com).

IMPORTANT!
- Change DirData to use the same Statics file than Cpanel Awstats and do not loose any entry.
(DirData=”/home/user/tmp/awstats/”)

Step 8.
Access AwStats by the URL:
www.yourdomain.com/

Category: PHP, Third party script issue  Comments off

Send mail by using phpmail function.

You can create a simple php mail form by using following code..

————————–

<?
$to      = ’supp0rt@xyz.com’;
$subject = ‘The test for mail function’;
$message = ‘Hello’;
$headers = ‘From: test@abc123.com’ . “\r\n” .
‘Reply-To: test@testforever123.com’ . “\r\n” .
‘X-Mailer: PHP/’ . phpversion();
mail($to, $subject, $message, $headers);
?>

————————–

If you are not able to receive the E-mail then you need to check whether your server is allowing to send an E-mail by using phpmail() or not?’ if you are having root login then check the servers main php.ini file.

root@Gunjan []# php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini

root@Gunjan []# cat /usr/local/lib/php.ini | grep disable_function
disable_functions=”system,passthru,popen,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,highlight_file,phpmail”

and remove the phpmail() from server mail php.ini file and restart the Apache web server.

Or

If you are not having root login details then contact your hosting provider and ask them to enable the phpmail() for your hosting account.

You can also send me an E-mail at nsk.gunjan@gmail.com if you have any queries…

PHP values you can change from .htaccess

There are few good values which should be change for specific script. Use following code in .htaccess to changes the values as per your requirement.

php_flag session.use_trans_sid off
php_flag session.use_only_cookies on
php_flag register_globals On
php_value magic_quotes_runtime Off
php_flag magic_quotes_gpc off
php_admin_flag safe_mode Off

php_value post_max_size 20971520
php_value upload_max_filesize 12M
php_value max_execution_time 600
php_value magic_quotes_gpc off
php_flag session.bug_compat_warn off
php_value session.use_cookies 1
php_flag session.use_only_cookies 1

Enable private PHP Error Logging via .htaccess\disable PHP Error Logging for visitor

To hide PHP errors from visitors insert the following code in .htaccess

# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off

Once disable the error logs for visitors enable the private PHP error logging by using following code in .htaccess

# enable PHP error logging
php_flag log_errors on
php_value error_log /home/path/public_html/domain/PHP_errors.log

The PHP_errors.log file needs to be permission 755 or 777.