Thursday, February 7, 2013

One Login For Multiple Wordpress

WordPress is web software you can use to create a beautiful website or blog. We like to say that WordPress is both free and priceless at the same time.

One Login For Mutiple Wordpress Blog Or Site Using Single Database.In order to be able to share a session cookie between both sites just use below code for it.



1) Sub Directory 
    Example : example.com , example.com/stuff , example.com/tutorials
          If you use sub directory you can follow this step:

Step 1 : Open Config File (Main wordpress setup) and add below code.

$baseurl = 'http://localhost/wordpress'; // replace with your main blog url
$cookiehash = md5($baseurl);

define('COOKIE_DOMAIN', false);
define('ADMIN_COOKIE_PATH', '/');
define('COOKIEPATH', '/');
define('SITECOOKIEPATH', false);
//define('COOKIEHASH', 'vy48u9w38868t7t99jh8g137x221r5h1h8');
define('COOKIEHASH', $cookiehash);
define('AUTH_KEY',         'qKuU:a]Zc9PfkXIN@e%[>)kl+EjNK!M; AGerZfz_LdK)LEF[v@LGx4efm-u)v`y');
define('SECURE_AUTH_KEY',  'aCDUFGo3[eKwh^h+xGZF^+J#XS|{BoW_on;}$pm*qWH4nWy`QxyaT^uirF!*`*O3');
define('LOGGED_IN_KEY', 'mywu969v3tcf2uer82vxisx8k6sq2neib5qs1qt4sx383slslb5t1xep12hbtcxs');
define('NONCE_KEY', 'bde6j26r93lvwmgwydw7x3kp74r5299q8vxe832y7r616lf215142e5t4vc55j36');
define('AUTH_SALT', '3856m559klvidrx34fi574ct32r94x77bepr7638jmuw22d29883i82k76un2tm4');
define('LOGGED_IN_SALT', 'jq4p67bv772nd73w4zm6286552x755v6293qpj5fbe34fxy894trdu77h38586n2');
define('SECURE_AUTH_SALT', 'i9hlmd67n21j2u485645in9vu6v92itgfmja6bjfbc36gqc673svlis9u789316p');
define('TEST_COOKIE', 'TEST_COOKIE'.COOKIEHASH);


Step 2 : Open Config File (Sub directory wordpress setup) and add below code.

 $baseurl = 'http://localhost/wordpress'; // replace with your main blog url
$cookiehash = md5($baseurl);

define('COOKIE_DOMAIN', false);
define('ADMIN_COOKIE_PATH', '/');
define('COOKIEPATH', '/');
define('SITECOOKIEPATH', false);
//define('COOKIEHASH', 'vy48u9w38868t7t99jh8g137x221r5h1h8');
define('COOKIEHASH', $cookiehash);
define('AUTH_KEY',         'qKuU:a]Zc9PfkXIN@e%[>)kl+EjNK!M; AGerZfz_LdK)LEF[v@LGx4efm-u)v`y');
define('SECURE_AUTH_KEY',  'aCDUFGo3[eKwh^h+xGZF^+J#XS|{BoW_on;}$pm*qWH4nWy`QxyaT^uirF!*`*O3');
define('LOGGED_IN_KEY', 'mywu969v3tcf2uer82vxisx8k6sq2neib5qs1qt4sx383slslb5t1xep12hbtcxs');
define('NONCE_KEY', 'bde6j26r93lvwmgwydw7x3kp74r5299q8vxe832y7r616lf215142e5t4vc55j36');
define('AUTH_SALT', '3856m559klvidrx34fi574ct32r94x77bepr7638jmuw22d29883i82k76un2tm4');
define('LOGGED_IN_SALT', 'jq4p67bv772nd73w4zm6286552x755v6293qpj5fbe34fxy894trdu77h38586n2');
define('SECURE_AUTH_SALT', 'i9hlmd67n21j2u485645in9vu6v92itgfmja6bjfbc36gqc673svlis9u789316p');
define('TEST_COOKIE', 'TEST_COOKIE'.COOKIEHASH);


define('CUSTOM_USER_TABLE', 'wp_users');
define('CUSTOM_USER_META_TABLE', 'wp_usermeta');



Step 3 : Open capabilities.php File (Sub Directory wordpress setup) and add below code.
(C:\xampp\htdocs\wordpress\wp-includes\capabilities.php)

Goto line no:709 and change below line

$this->cap_key = $wpdb->prefix . 'capabilities';

Change to : (main wordpress database prifix)

$this->cap_key = $wpdb-> 'wp_capabilities'; 

Monday, February 4, 2013

Check if a string contains numbers by Mysql

how do I check if a string in a MySQL field contains a number then delete them?
 
tbl_tags
 -------------
| id | tag    |
 -------------
| 1  | hello  |
| 2  | hello2 |
| 3  | 2hello |
| 4  | hel3lo |
                   -------------

The only way I can think of is to do each number individually and use LIKE '%1%' OR LIKE '%2%' etc. But there must be an easier way?

Check out the MySQL Regex methods. Something like the following should work.
SELECT * FROM table WHERE tag REGEXP '[0-9]'


Replace character or word using Sql Query

Hi Friends,
Here We learn about how to replace string,character or word to given string using mysql or sql query.For doing this you can use " REPLACE() " Function.
Example :
UPDATE tablename SET fieldname = REPLACE(fieldname,'OLD TEXT','NEW TEXT')

Tuesday, January 22, 2013

Difference Between Perl and CGI

CGI is a standard that provides an interface between a webserver, such as Apache, and clients through a (CGI) script, which can be written in any programming language. However, scripting languages are often used. CGI Scripts take the request from client and will call appropriate functions to return the result to the requested clients. There are many language that could function as CGI language like Perl, C, C++, Tcl, Unix Shell Script, etc. However, Perl is without a doubt the most used languages for CGI scripting.

Perl is itself a high-level, interpreted, dynamic programming language. It was originally developed way back in 1987 to make generating reports easier. It caught on with programmers and has grown and expanded ever since, leading up to the latest release of Perl 6. Perl borrows features from other programming languages including C, shell scripting (sh), AWK, and sed. The language provides powerful text processing facilities without the arbitrary data length limits of many contemporary Unix tools, facilitating easy manipulation of text files. It is also used for system administration, network programming, and applications that require database access. Perl is nicknamed “the Swiss Army chainsaw of programming languages” due to its flexibility and adaptability.

Page Refresh using php script

This a nice one in php.A Refresh or reload or redirect page using php script or function.just amazing functionality provide by php.Here we can not require any javascript,jquery or ajax to do this.Use only simple php " header() " function to perform this task.We can use this function any where in project or website.




Example :

//refresh after 5 second
header("refresh:5;");

//reload after 5 second to specific path
header("refresh:5; test.php");