Author:
erics , December 15th, 2011
Below information copied without permission from Josh Sharp’s site because it is too valuable to lose – great work Josh, and THANKS!
RewriteEngine On
RewriteCond % { REQUEST_FILENAME } ! - d
RewriteCond % { REQUEST_FILENAME } ! - f
RewriteRule ^ ( . * ) $ index . php ? url = $ 1 [ QSA , L ]
Note: Only rewrite if the requested file is not an existing directory (-d) or a file (-f)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
include ( 'app/classes.php' ) ;
include ( 'app/app.php' ) ;
//init our app
$ App = new App ;
//grab the mod_rewrite url
$ url = $ _REQUEST [ 'url' ] ;
//if the url is empty then the user has navigated just to root
if ( $ url == '' ) {
//start with default controller
$ App -> setController ( 'home' ) ;
} else {
//grab each part of our URL - controller, action, and identifier
$ path = explode ( '/' , $ url , 3 ) ;
//pass these onto the app to handle
$ App -> setController ( $ path [ 0 ] , $ path [ 1 ] , $ path [ 2 ] ) ;
}
Categories: How-To's , Technology Tags: apache , mod_rewrite , module , Path , php , Rewrite , SEO , URL
| No comments
Author:
erics , December 1st, 2011
PHP number_format($number, 2, ‘.’, ‘,’); SMARTY {$number|number_format:2:”.”:”,”}
Categories: How-To's , Technology Tags: Format , howto , Number , php , Smarty , tips
| No comments
Author:
erics , November 9th, 2011
date_default_timezone_set ( 'America/New_York' ) ;
$ datetime1 = new DateTime ( '2009-10-31' ) ;
$ datetime2 = new DateTime ( 'now' ) ;
$ interval = $ datetime1 -> diff ( $ datetime2 ) ;
print $ interval -> format ( '%a days_elapsed' ) ;
http://www.php.net/manual/en/datetime.diff.php
Categories: How-To's , Technology Tags: Date , Date Math , Delta , diff , Difference , Elapsed , howto , Math , php , time , tips
| No comments
Author:
erics , August 22nd, 2011
# service httpd stop
# yum erase php-common php
# yum install php53*
# service httpd start
To get mcrypt installed, read this post: http://www.ericmichaelstone.com/?p=4702
Categories: How-To's , Technology Tags: CentOS , Erase , howto , Install , mcrypt , php , PHP53 , tips , upgrade , Yum
| No comments
Author:
erics , August 12th, 2011
To get mcrypt support for PHP 5.3, compile and install just the mcrypt extension. First, get the prerequisites:
yum install php53 - devel libmcrypt - devel gcc gcc - c ++
Download the php source code from php.net, for example:
wget http : //mx2.php.net/get/php-5.3.6.tar.bz2/from/us3.php.net/mirror
tar xvjf php - 5.3.6.tar.bz2
Now, cd to the proper place and follow these steps:
cd php - 5.3.6 / ext / mcrypt /
phpize
aclocal
. / configure
make
make install
Create the configuration file for MCrypt /etc/php.d/mcrypt.ini containing:
Restart apache:
Create a file […]
Categories: How-To's , Technology Tags: compile , gcc , howto , Install , libmcrypt , mcrypt , mcrypt.ini , mcrypt.so , php , PHP53 , phpmyadmin , tips
| 2 comments
Author:
erics , July 29th, 2011
Create a file called export.php in the wordpress top directory containing the following (remember to add the PHP tags at the top and bottom):
include 'wp-config.php' ;
include 'wp-admin/includes/export.php' ;
ob_start ( ) ;
export_wp ( ) ;
$file = ob_get_contents ( ) ;
ob_end_clean ( ) ;
$fh = fopen ( "wordpress-" . date ( 'Y-m-d' ) . ".xml" , 'w' ) ;
fwrite ( $fh , $file ) ;
fclose ( $fh ) ;
Categories: Rants Tags: cli , Command line , Export , php , WordPress
| 3 comments
Author:
erics , July 28th, 2011
For example, $mime_type could equal “image/jpeg”…
$file_info = new finfo ( FILEINFO_MIME ) ;
$mime_type = $file_info -> buffer ( file_get_contents ( $file ) ) ;
- or -
$filename = $_SERVER [ 'SCRIPT_FILENAME' ] ; // Could also use REQUEST_URI, PATH_INFO or ORIG_PATH_INFO
$finfo = finfo_open ( FILEINFO_MIME ) ; // return mime type ala mimetype extension
$mime = finfo_file ( $finfo , $filename ) ;
finfo_close ( $finfo ) ;
header ( "Content-type:$mime" ) ;
readfile ( "$filename" ) ;
http://www.php.net/manual/en/function.finfo-file.php http://www.w3schools.com/php/func_http_header.asp http://www.php.net/manual/en/reserved.variables.server.php
Categories: How-To's , Technology Tags: File type , file_get_contents , file_info , finfo , Mime , Mime Type , php
| No comments
Author:
erics , January 18th, 2011
Since I have completely unloaded FastCGI from Apache since moving to suPHP, I have seen a massive improvement overall. FastCGI is dead as far as I am concerned. Catalyst runs just fine without it. IMHO it is a serious kludge and should not be used. I am sorry I ever laid hands on it to […]
Categories: How-To's , Technology Tags: apache , FastCGI , php , suPHP , Waste
| No comments
Author:
erics , January 18th, 2011
After running my PHP instances in FastCGI for a while, I have not been satisfied with the performance, and have switched over to suPHP instead. The security benefits are there, and the memory footprint much smaller, with no drop in performance. In fact, this has solved some odd delays with the FastCGI implementation. I am […]
Categories: How-To's , Technology Tags: apache , FastCGI , php , suPHP
| No comments
Author:
erics , December 30th, 2010
EDIT Jan 23, 2017: The FastCGI website is down so the below links no longer work. mod_fcgid is another possibility, and is the official Apache-supported method, but may be less performant that mod_fastcgi: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html New write-up to follow when time allows… Thanks to Tara Senn of whoishostingthismail.com for pointing out the broken links to me! […]
Categories: How-To's , Technology Tags: FastCGI , FastCgiConfig , FastCgiServer , mod_fastcgi , php , WordPress
| No comments