Use WordPress to Setup Multi Blogs Under One Mysql Database

We can use Mu to setup multi wordpress blogs. If you do not want to do so, you can use wordpress to setup multiy blogs also.

 For example, we want to set up two blogs: www.glassespeople.com ,and http://blog.glassespeople.com, we only add the following code at wp-config.php: (more…)

Posted in Php Code, WordPress. Comments Off on Use WordPress to Setup Multi Blogs Under One Mysql Database »

2 Methods to show wordpress lastest posts at other site

Method one, we can show other wordpress posts at our site by using  simplepie.inc, download a wordpress plugin, named “simplepie-core”, and upload simplepie.inc to your site root, you can rename simplepie.inc to other name also, ie, eyeglassframes.inc.

Then add the following code at your own site .php file. (more…)

Posted in Php Code, Php Skills, WordPress. Comments Off on 2 Methods to show wordpress lastest posts at other site »

Display Domain Name

How would I display the domain name of the page I am at. Lets say it it http://www.eyeglasseshut.com/comfortable-prescription-eyeglasses.htm and I want to display desilva.biz. Exactly like that. No www, or http:// included.

In fact, it is very use to let PHP do such thing:

$hostname = $_SERVER[‘SERVER_NAME’];
$hostname = str_replace(‘www.’, , $hostname);

echo $hostname;

Posted in Php Code. Comments Off on Display Domain Name »

How to add 10 hot wordpress posts

If you want to add 10 host post at your right bar, just copy and past the following code:

<h2>Hot PHP Posts</h2>
<ul>
<?php $result = $wpdb->get_results(“SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 10″);
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li><a href=”<?php echo get_permalink($postid); ?>” title=”<?php echo $title ?>”>
<?php echo $title ?></a> (<?php echo $commentcount ?>)</li>
<?php } } ?>
</ul>

Posted in Php Code, WordPress. Comments Off on How to add 10 hot wordpress posts »

Using PHP to Generate Strong Password

If you want to have very strong password to protect your account, here is the code for :

<code>
<?php
 
function generatePassword($length=9, $strength=0) {
    $vowels = ‘aeuy’;
    $consonants = ‘bdghjmnpqrstvz’;
    if ($strength & 1) {
        $consonants .= ‘BDGHJLMNPQRSTVWXZ’;
    }
    if ($strength & 2) {
        $vowels .= “AEUY”;
    }
    if ($strength & 4) {
        $consonants .= ‘23456789’;
    }
    if ($strength & 8) {
        $consonants .= ‘@#$%’;
    }
 
    $password = ”;
    $alt = time() % 2;
    for ($i = 0; $i < $length; $i++) {
        if ($alt == 1) {
            $password .= $consonants[(rand() % strlen($consonants))];
            $alt = 0;
        } else {
            $password .= $vowels[(rand() % strlen($vowels))];
            $alt = 1;
        }
    }
    return $password;
}
 
?>
</code>

Posted in Php Code, Php Study. Comments Off on Using PHP to Generate Strong Password »

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: (more…)

Posted in Php Code. Comments Off on Using PHP to Transfer Chinese Character Into Pinyin? »

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.
0)
{
@header(“Location: /wap/”);
}

?>


Cheap Glasses



Cheap Prescription Glasses, and Non-Prescription Glasses.


Page 2.





Cheap Glases Mobile


Cheap Prescription Glasses Mobile

Cheap Non-Prescription Glasses Mobile



Live Demo: www.cheapglasses.mobi

Posted in Php Code. Comments Off on Redirect by PC or mobile phone access »

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.

'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.

Posted in Php Code, Vbulletin. Comments Off on Share 1 set vbulletin code with multi vbulletin forums in one host »

Delet category and documents powerfully

';
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.

Posted in Php Code. Comments Off on Delet category and documents powerfully »

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

Posted in Php Code. Comments Off on CPA/CPL affiliate networks that show targeted ads »
King Php Science Welcome, you are from: 54.162.125.164