-
Archives
- January 2012
- December 2011
- September 2011
- August 2011
- June 2011
- January 2011
- December 2010
- November 2010
- October 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- January 2009
- November 2008
- September 2008
- August 2008
- July 2008
- March 2008
- February 2008
- January 2008
-
Meta
Category Archives: PHP
Multibyte PHP Functions
Source: Using Multi-Byte Character Sets in PHP (Unicode, UTF-8, etc) The following list details the PHP string functions which could cause problems when handling multi-byte strings. The multi-byte safe alternative is given when available: mail() Try mb_send_mail() instead. strlen() Try mb_strlen() instead. strpos() Try mb_strpos() instead. … Continue reading
Inserting a troublesome string from PHP to Javascript
<script type=”text/javascript”> alert(“<?php echo preg_replace(“/\r?\n/”, “\\n”, addslashes($message)); ?>”); </script> Passing variables to Javascript
How to get next MySQL insert id
function getMysqlInsertID($tablename) { $next_increment = 0; $qShowStatus = “SHOW TABLE STATUS LIKE ‘$tablename’”; $qShowStatusResult = mysql_query($qShowStatus) or die ( “Query failed: ” . mysql_error() . “<br/>” . $qShowStatus ); $row = mysql_fetch_assoc($qShowStatusResult); $next_increment = $row['Auto_increment']; return $next_increment; }
Run php as cronjob with safe_mode setting
/usr/bin/php -d safe_mode=Off script_to_run.php
ctags for php
$ cd /path/to/phpcode $ ctags -f /output/tags \ -h “.php” -R \ –exclude=”\.svn” \ –totals=yes \ –tag-relative=yes \ –PHP-kinds=+cf \ –regex-PHP=’/abstract class ([^ ]*)/\1/c/’ \ –regex-PHP=’/interface ([^ ]*)/\1/c/’ \ –regex-PHP=’/(public |static |abstract |protected |private )+function ([^ (]*)/\2/f/’ exuberant ctags with … Continue reading
PHP deprecated eregi, ereg_replace, split replacement
Deprecated eregi($pattern, $haystack); Replacement preg_match(‘/’ . $pattern . ‘/i’, $haystack); Deprecated ereg_replace($pattern, $replacement, $haystack); Replacement preg_replace(‘/’ . $pattern . ‘/’, $replacement, $haystack); Deprecated split(“[:,]“, “1:2,3:4,5:6″); … Continue reading
Prohibit execution of PHP scripts inside include directory
Create a PHP file /** * prepend_goto_index.php */ header(‘Location: http://’ . $_SERVER['HTTP_HOST']); Inside the include directory, create .htaccess file php_value auto_prepend_file prepend_goto_index.php
Disable PHP in directory
In .htaccess php_flag engine off
How to create reverse traceroute page on your website using PHP
<?php $result = exec(‘traceroute ‘ . $_SERVER["REMOTE_ADDR"], $lines); echo ‘<h1>Your IP is ‘ . $_SERVER["REMOTE_ADDR"] . ‘</h1>’; echo ‘<pre>’; foreach ($lines as $n => $line) { if ($n) echo ‘<br />’; echo $line; } echo ‘</pre>’; echo ‘<p>-end-</p>’; Here’s how … Continue reading
Posted in Linux Administration, PHP, Programming
Tagged PHP, reverse traceroute, traceroute
Leave a comment