Saturday, July 17, 2010

How to login multiple word press sites with single login

If there is two or more than wordpress sites with in a main wordpress.Like child word press, and we wanna enter the admin of all sites with the single login
for this we need to add the code for using same user table for this we will add code in wp-config.php of child wordpress.
Suppose we have wp_users table in parent wordpress and wp_child_user for child wordpress. the idea is that we have to use same credentials for all wordpress. so we need to add code for to use the user table of parent wordpress
so open the wp-config.php of child wordpress.
define('CUSTOM_USER_TABLE','wp_users'); // shared user db
define('CUSTOM_USER_META_TABLE','wp_usermeta'); // shared usermeta
now replace the
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
line of both config.php files with
define('AUTH_KEY',        ')6ymo_O2f(?oF&Zm<#p+&UMlnrBpfKs]HL`@@uH}vt%]X(7&U@rw&`_;-M3xi])/');
define('SECURE_AUTH_KEY', 'sLh`1v7sZM-X#|%/0b<7OCX*UYyR{bmAVNZi=BZrU/<g/x -=8(Dv*~zb+G>q)$|');
define('LOGGED_IN_KEY',   'dQ;JHn8c(K!%[zi+lzd3<CfX9 z$~/<+M@qLt%Lq$|c%~6=X_9RN)SHIm=f5j<-i');
define('NONCE_KEY',       'OauPeHLGei#I_f**YiS!u!-|#|4^=}RKbs;oc8Ox[-XpULusT )C fT;X@<5}<FR');
define('AUTH_SALT', 'Oxiw7VX@XA5y$j$U^Ox^z$4682F2*sAI2yc@nvgZSikRZnJGmnz0EfulzMx0uBoO');
define('LOGGED_IN_SALT', 'p*d79LVP0b3l6&F0JixVYUrg&B&s&KNNqfn5gy2qXrBaw1MkBAypNkcEv$sz7i(T');
Now open the wp-setting.php file of child wordpress
and go to the line
define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
replace it with
define('COOKIEPATH','//');
Now go to
define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
replace it with
define('SITECOOKIEPATH','//');
Now go to
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
replace it with
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . '' );
now go to
define('COOKIEHASH', md5(get_option('siteurl')))
replace it with
define('COOKIEHASH', md5())
Do the same for parent worpress's wp-setting.php file

Now open the wp-includes/capabilities.php file of child word press
goto the code:
function _init_caps() {
  global $wpdb;
 $this->cap_key = $wpdb->prefix . 'capabilities';
  $this->caps = &$this->{$this->cap_key};
  if ( ! is_array( $this->caps ) )
   $this->caps = array();
  $this->get_role_caps();
 }
and replace the 2nd line of the _init_caps with
$this->cap_key = 'wp_capabilities';

Monday, July 12, 2010

How to add custom input type in RS-Form in joomla rather than textboxes(when you edit form's data)

For this you need to go
\components\com_rsform\controller\ajax.js
and go to function editRow(id, total)
in this function you can add custom input type
For an example ::
function editRow(id, total)
{
 for(var i=0; i < total; i = i +1)
 {
  value = document.getElementById("textarea-" + id + "-" + i).innerHTML;

  if (value.match(/\n/ig))
  {
   
    document.getElementById("row-" + id + "-" + i).innerHTML = "";
  }
  else
  { 
    if(i=="3"){
      document.getElementById("row-" + id + "-" + i).innerHTML = "";
     
     }
    else{
   document.getElementById("row-" + id + "-" + i).innerHTML = "";        }
  }
 }

 document.getElementById("act-" + id).innerHTML = "" + "" + "";
}

In this code I have added dropdown when i==3 using code::
 if(i=="3"){
      document.getElementById("row-" + id + "-" + i).innerHTML = "";
     
     }
    else{ 

Friday, July 9, 2010

How to login in joomla site through php site...

If I entered in php site with any credentials and want to access joomla admin with the same credentials (need not to fill joomla login form)


e.g. if i have a core php site with the url http://192.168.1.201/care1/
and a joomla site with url------http://192.168.1.201/delta_strike1/administrator/

go to login function in php site: http://192.168.1.201/care1/
and set the cookies as :
setcookie("username", $username, time()+3600, "/delta_strike1/");
setcookie("passwd", $passwd, time()+3600, "/delta_strike1/");
please take care of fourth variable of set cookie function.

Now open your joomla site folder and go to \\Demo\php\delta_strike1\administrator\modules\mod_login

open mod_login.php
Note: I have copied all the code of mod_log.php and that is :-->
<?php

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.language.helper');
//$browserLang = JLanguageHelper::detectLanguage();
// forced to default
$browserLang = null;
$lang =& JFactory::getLanguage();

$languages = array();
$languages = JLanguageHelper::createLanguageList($browserLang );
array_unshift( $languages, JHTML::_('select.option',  '', JText::_( 'Default' ) ) );
$langs = JHTML::_('select.genericlist',   $languages, 'lang', ' class="inputbox"', 'value', 'text', $browserLang );
?>
<?php if(JPluginHelper::isEnabled('authentication', 'openid')) :
$lang->load( 'plg_authentication_openid', JPATH_ADMINISTRATOR );
$langScript =  'var JLanguage = {};'.
' JLanguage.WHAT_IS_OPENID = \''.JText::_( 'WHAT_IS_OPENID' ).'\';'.
' JLanguage.LOGIN_WITH_OPENID = \''.JText::_( 'LOGIN_WITH_OPENID' ).'\';'.
' JLanguage.NORMAL_LOGIN = \''.JText::_( 'NORMAL_LOGIN' ).'\';'.
' var modlogin = 1;';
$document = &JFactory::getDocument();
$document->addScriptDeclaration( $langScript );
JHTML::_('script', 'openid.js');
endif; ?>
<?php
$flag =0;
if($error = JError::getError(true)) {
$flag =1;
}
?>

<form action="<?php echo JRoute::_( 'index.php', true, $params->get('usesecure')); ?>" method="post" name="login" id="form-login" style="clear: both;">
<p id="form-login-username">
<?php if($flag==0){?>
<input name="username" id="modlgn_username" type="hidden" value="<?php echo  $_COOKIE['username'];?>" />
<input name="passwd" id="modlgn_passwd" type="hidden" value="admin"/>
<?php } ?>
<?php 
if($flag==1){?>
<label for="modlgn_username"><?php echo JText::_('Username'); ?></label>
<input name="username" id="modlgn_username" type="text" class="inputbox" size="15" />
</p>

<p id="form-login-password">
<label for="modlgn_passwd"><?php echo JText::_('Password'); ?></label>
<input name="passwd" id="modlgn_passwd" type="password" class="inputbox" size="15" />
<?php }
elseif(!isset($_COOKIE['username']) ){?>
<label for="modlgn_username"><?php echo JText::_('Username'); ?></label>
<input name="username" id="modlgn_username" type="text" class="inputbox" size="15" />
</p>

<p id="form-login-password">
<label for="modlgn_passwd"><?php echo JText::_('Password'); ?></label>
<input name="passwd" id="modlgn_passwd" type="password" class="inputbox" size="15" />
<?php } ?>
</p>
<?php
if($error = JError::getError(true)) {
echo '<p id="login-error-message">';
echo $error->get('message');
echo '<p>';
}
?>
<p id="form-login-lang" style="clear: both;">
<label for="lang"><?php echo JText::_('Language'); ?></label>
<?php echo $langs; ?>
</p>
<div class="button_holder">
<div class="button1">
<div class="next">
<a onclick="login.submit();">
<?php echo JText::_( 'Login' ); ?></a>

</div>
</div>
</div>
<div class="clr"></div>
<input type="submit" style="border: 0; padding: 0; margin: 0; width: 0px; height: 0px;" value="<?php echo JText::_( 'Login' ); ?>" />
<input type="hidden" name="option" value="com_login" />
<input type="hidden" name="task" value="login" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
<?php
if($flag==1){}
elseif(isset($_COOKIE['username'])){?>
<script type="text/javascript" language="javascript">
document.login.submit();
</script>
<?php }?>

Now try it. It will work
Note: this is unsecure and totaly farji code but it will solve your purpose

Thursday, July 8, 2010

Wel Come to desi code


my original and 100% desi code will be available to you very shortly..