Using PHP to Transfer Chinese Character Into Pinyin?

If you want to transfer Chinese Character into pinyin, you can creat a php file, say hanzi2pinyin.php, and copy the following PHP code: Read the rest of this entry »

Redirect by PC or mobile phone access

Just the same domain, using the following code, you can let your computer and mobile phone show different contents. We have to design 2 pages, all named index.php, the first one will be put at your host root, and the other one will be put under wap.
Page 1.
$iswap = isset($_SERVER['HTTP_ACCEPT'])? $_SERVER['HTTP_ACCEPT']:'';
if(strpos($iswap,"wap")>0)
{
@header(”Location: /wap/”);
}

?>




Cheap Prescription Glasses, and Non-Prescription Glasses.


Page 2.





Cheap Prescription Glasses Mobile

Cheap Non-Prescription Glasses Mobile



Live Demo: www.cheapglasses.mobi

Share 1 set vbulletin code with multi vbulletin forums in one host

If you have several vbulletin licenses, and you only have very small web hosting. I can tell you a skill on how to share one set vbulletin code with multi vbulletin licenses.

add the following to config.php.

$arrays=array(
'localhost'=>‘configlocalhost.php’,
‘127.0.0.1′=>’config127.php’,
);
$url = $arrays[$_SERVER[’HTTP_HOST’]];
include $url;
?>

and change the other 2 forums’ config.php to configlocalhost.php and config127.php.

that’s all.

Delet category and documents powerfully

function myrmdir($parth)
{
$handle=opendir($parth);
while ($file = readdir($handle))
{
if ($file=='..' || $file=='.') continue;
if (is_file($parth.'/'.$file))
{
echo 'del document:'.$parth.'/'.$file.'
‘;
unlink($parth.’/’.$file);
}
else myrmdir($parth.’/’.$file);
}
closedir($handle);
echo ‘del category:’.$parth.’
‘;
rmdir($parth);
}
myrmdir(’myparth’);
?>

Chang myparth to the path you plan to del, save as del.php, upload del.php to the space you want to del document or category. All the files will be deleted.

CPA/CPL affiliate networks that show targeted ads

That is what I get for my browser.
Something like this would work well.
$langdone == false;
if (preg_match(”/en-gb/siU”, $_SERVER[”HTTP_ACCEPT_LANGUAGE”]) == 1) {
 echo “echo your en gb links/banner”;
 $langdone == true;
}
if (preg_match(”/en-us/siU”, $_SERVER[”HTTP_ACCEPT_LANGUAGE”]) == 1) {
 echo “echo your en us links/banner”;
 $langdone == true;
}
// default
if ($langdone==false) {
 echo "echo your default links/banner";
}
?>

In php preg_match the s = treat as string, not exactly needed as there are no new lines, i = case insensitive and U = ungreedy

Generate a phrase to url.

str_replace
(PHP 4, PHP 5)

str_replace — Replace all occurrences of the search string with the replacement string

$vowels = array(”a”, “e”, “i”, “o”, “u”, “A”, “E”, “I”, “O”, “U”);
$onlyconsonants = str_replace($vowels, “”, “Hello World of PHP”);

How to write IE specific PHP

if((ereg("Nav", getenv("HTTP_USER_AGENT"))) || (ereg("Gold", getenv("HTTP_USER_AGENT"))) || (ereg("X11", getenv("HTTP_USER_AGENT"))) || (ereg("Mozilla", getenv("HTTP_USER_AGENT"))) || (ereg("Netscape", getenv("HTTP_USER_AGENT"))) AND (!ereg("MSIE", getenv("HTTP_USER_AGENT")) AND (!ereg("Konqueror", getenv("HTTP_USER_AGENT"))))) $browser = "Netscape";
elseif(ereg("MSIE", getenv("HTTP_USER_AGENT"))) $browser = "MSIE";
elseif(ereg("Lynx", getenv("HTTP_USER_AGENT"))) $browser = "Lynx";
elseif(ereg("Opera", getenv("HTTP_USER_AGENT"))) $browser = "Opera";
elseif(ereg("WebTV", getenv("HTTP_USER_AGENT"))) $browser = "WebTV";
elseif(ereg("Konqueror", getenv("HTTP_USER_AGENT"))) $browser = "Konqueror";
elseif((eregi("bot", getenv("HTTP_USER_AGENT"))) || (ereg("Google", getenv("HTTP_USER_AGENT"))) || (ereg("Slurp", getenv("HTTP_USER_AGENT"))) || (ereg("Scooter", getenv("HTTP_USER_AGENT"))) || (eregi("Spider", getenv("HTTP_USER_AGENT"))) || (eregi("Infoseek", getenv("HTTP_USER_AGENT")))) $browser = "Bot";
else $browser = "Other";

this will return the browser name in $browser

and you can have a test at http://www.botsvsbrowsers.com/SimulateUserAgent.asp.

example:

if(ereg(”Google”, getenv(”HTTP_USER_AGENT”))) $browser = “Bot”;
else $browser = “Other”; 

echo $browser;

Plugin for limit the size of the post in the main page in WordPress

The  plugin  for WordPress in order to control the maximum amount of characters displayed for an entry on the main page. If the set limit is surpassed a link to a page with the whole content will appear and the text on the entry will be chopped to that amount of characters, otherwise the content will be showed unchanged. Read the rest of this entry »

How to add ads only at the first post?

It is very simple:

<?php if ($wp_query->current_post == 0) : ?>

<div style=”float:right”>

ads come here.

</div>
<?php endif; ?>

If you don’t want the ads show at homepage, using:

<?php if (!is_home()) ?>

Sending Email (Text/HTML/Attachments)

Email is the most popular Internet service today. A plenty of emails are sent and delivered each day. The goal of this tutorial is to demonstrate how to generate and send emails in PHP.

So, you want to send automated email messages from your PHP application. This can be in direct response to a user’s action, such as signing up for your site, or a recurring event at a set time, such as a monthly newsletter. Sometimes email contains file attachments, both plain text and HTML portions, and so on. To understand how to send each variation that may exist on an email, we will start with the simple example and move to the more complicated.

Sending a Simple Text Email
Sending HTML Email
Sending Email with Attachments
Note that to send email with PHP you need a working email server that you have permission to use: for Unix machines, this is often Sendmail; for Windows machines, you must set the SMTP directive in your php.ini file to point to your email server.

Sending a Simple Text Email Read the rest of this entry »