Back to top

Autore Topic: [risolto]Re:Come Joomla registra password?????  (Letto 5278 volte)

pippo30

  • Visitatore
[risolto]Re:Come Joomla registra password?????
« il: 19 Apr 2013, 17:09:12 »
Codice: [Seleziona]

$salt       = JUserHelper::genRandomPassword(32);
                $crypted    = JUserHelper::getCryptedPassword($pwd, $salt) . ':' . $salt;
                $newpassword= $crypted . ':' . $salt;



66ef5564d2b51e90e8eb3001a275c304:yBHNNgTiBQYTzo1X4..password csv
fd8c5fc32d89843ffe861c5727058eab:eEORBOeZ3erYenV1r... password cambiata a mano
come mai???
« Ultima modifica: 23 Apr 2013, 11:34:49 da Marco31 »

Offline tomtomeight

  • Global Moderator
  • Fuori controllo
  • ********
  • Post: 32046
  • Sesso: Maschio
  • Gli automatismi aiutano ma non insegnano nulla.
    • Mostra profilo
Re:Come Joomla registra password?????
« Risposta #1 il: 19 Apr 2013, 18:57:56 »
Il salt è diverso se lo fa joomla rispetto a come lo fai tu a mano?

pippo30

  • Visitatore
Re:Come Joomla registra password?????
« Risposta #2 il: 20 Apr 2013, 01:48:12 »
io ho fatto un componente che imprta il csv utenti
sono riuscito a fare in modo che gli utenti si importino da csv le passord sono criptate male
se io le importo da csv sono diversere rispetto a quando vado a inserile nella gestione utenti e la modifico a mano.
se la stessa password la metto a mano funziona se la importo da csv ne cripta un'altra
se mi dai una mano ti rigrazio
« Ultima modifica: 22 Apr 2013, 09:14:26 da Marco31 »

Offline tomtomeight

  • Global Moderator
  • Fuori controllo
  • ********
  • Post: 32046
  • Sesso: Maschio
  • Gli automatismi aiutano ma non insegnano nulla.
    • Mostra profilo
Re:Come Joomla registra password?????
« Risposta #3 il: 20 Apr 2013, 06:40:37 »
Come le modifichi a mano?

pippo30

  • Visitatore
Re:Come Joomla registra password?????
« Risposta #4 il: 20 Apr 2013, 11:04:24 »
le modifico d'amministrazione utenti di joomla ti posto il mio controller.php

Codice: [Seleziona]


<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
// import Joomla controller library
jimport('joomla.application.component.controller');
 
/**
 * General Controller of JUserImporter component
 */
class JUserImporterController extends JControllerLegacy
{
        
/**
         * display task
         *
         * @return void
         */
        
function display($cachable false$urlparams = array()) 
        {
                
// set default view if not set
                
$input JFactory::getApplication()->input;
                
$input->set('view'$input->getCmd('view''JUserImporter'));
 
                
// call parent behavior
                
parent::display($cachable$urlparams);
        }
        
        
/**
         * Import task
         */
        
function importUsers($source "D:/xampp/htdocs/users2import.csv")
        {
            
/* Check the user file exists */
            /* Open the file */

            
if(!file_exists($source)) $source $_REQUEST['srcfile'];

            
$handle fopen($source,"r");
            
$content fread ($handle,filesize $source ));  
             
            
/* Get the file, line by line */
            
$lines explode("\n"$content);

            
fclose($handle); 
            
/* Counter of users added */
            
$added 0;
             
            
/* Iterate through each line of the data file */
            
foreach ($lines as $line){
                
/* Split the line by comma */
                
$properties explode(",",$line);

                
/* Build a new user object */
                
$user = new JUser();
                
$user->name $properties[0];
                
$user->username $properties[1];
                
$user->email $properties[2];
                
$user->password $properties[3];
                
$user->id null;
                 
                
/* Set the values */
                
$user->groups = array(2);
                require_once( 
JPATH_ROOT "/libraries/joomla/user/helper.php" ); // Needed to create password
                 
                
$salt       JUserHelper::genRandomPassword(32);
                
$crypted    JUserHelper::getCryptedPassword($pwd$salt) . ':' $salt;
                
$newpassword$crypted ':' $salt;

                 
                
$user->password $newpassword;
                
$user->registerDate date('Y-m-d H:i:s');
                
                if(!
$user->save()) JError::raiseError(500,$user->getError() );   
                else 
$added++;
            }

            if(
$added) return $added;
 
        
JError::raiseError(403JText::_('Ci sono stati degli errori.'));
        return 
false
        }
}



pensavo fosse la mancanza di questa riga:
require_once( JPATH_ROOT . "/libraries/joomla/user/helper.php" ); // Needed to create password che richiama helper.php
praticamente ho richiamato questo file che è il che genera l'hd5??? giusto??
« Ultima modifica: 22 Apr 2013, 09:15:33 da Marco31 »

pippo30

  • Visitatore
Re:Come Joomla registra password?????
« Risposta #5 il: 22 Apr 2013, 09:11:44 »
ciao ho provato a mettere in due array sia $salt che $crypt nn cambia nulla

Codice: [Seleziona]

$salt = JUserHelper::genRandomPassword(32);
                $crypt = JUserHelper::getCryptedPassword($array['password'], $salt);
               $array['password'] = $crypt . ':' . $salt;

Offline tomtomeight

  • Global Moderator
  • Fuori controllo
  • ********
  • Post: 32046
  • Sesso: Maschio
  • Gli automatismi aiutano ma non insegnano nulla.
    • Mostra profilo
Re:Come Joomla registra password?????
« Risposta #6 il: 22 Apr 2013, 09:44:30 »
Vedi se questa discussione ti può essere utile.
 
http://forum.joomla.it/index.php/topic,172915.msg780484.html#msg780484

pippo30

  • Visitatore
Re:Come Joomla registra password?????
« Risposta #7 il: 22 Apr 2013, 12:04:41 »
nn capidco come lo spiegano

Offline tomtomeight

  • Global Moderator
  • Fuori controllo
  • ********
  • Post: 32046
  • Sesso: Maschio
  • Gli automatismi aiutano ma non insegnano nulla.
    • Mostra profilo
Re:Come Joomla registra password?????
« Risposta #8 il: 22 Apr 2013, 12:49:27 »
In quella discussione l'utente ha utilizzato questo codice:

Codice: [Seleziona]
function password__serialize($username, $password){
$query = "SELECT id, gid, block, password, usertype FROM jos_users where username='".$username."'";
$risultato = mysql_query($query) or die("Query fallita: " . mysql_error() );
$linea = mysql_fetch_array($risultato, MYSQL_ASSOC);
    /* Liberazione delle risorse del risultato */
mysql_free_result($risultato);

$arraypass=explode(":", $linea['password']);
$salt=$arraypass[1];
   
$ret = md5(trim($password).$salt).":".$salt;
return $ret;
}
$username = "pippo";
$password = "pippo";


echo password__serialize($username, $password);


« Ultima modifica: 22 Apr 2013, 12:54:07 da tomtomeight »

pippo30

  • Visitatore
Re:Come Joomla registra password?????
« Risposta #9 il: 22 Apr 2013, 15:32:31 »
Codice: [Seleziona]
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
// import Joomla controller library
jimport('joomla.application.component.controller');
 
/**
 * General Controller of JUserImporter component
 */
class JUserImporterController extends JControllerLegacy
{
        
/**
         * display task
         *
         * @return void
         */
        
function display($cachable false$urlparams = array()) 
        {
                
// set default view if not set
                
$input JFactory::getApplication()->input;
                
$input->set('view'$input->getCmd('view''JUserImporter'));
 
                
// call parent behavior
                
parent::display($cachable$urlparams);
        }
        
        
/**
         * Import task
         */
        
function importUsers($source "e:/xampp/htdocs/users2import.csv")
        {
            
/* Check the user file exists */
            /* Open the file */

            
if(!file_exists($source)) $source $_REQUEST['srcfile'];

            
$handle fopen($source,"r");
            
$content fread ($handle,filesize $source ));  
             
            
/* Get the file, line by line */
            
$lines explode("\n"$content);

            
fclose($handle); 
            
/* Counter of users added */
            
$added 0;
             
            
/* Iterate through each line of the data file */
            
foreach ($lines as $line){
                
/* Split the line by comma */
                
$properties explode(",",$line);

                
/* Build a new user object */
                
$user = new JUser();
                
$data = array();
                
$data['name'] = $properties[0];
                
$data['username'] = $properties[1];
                
$data['email'] = $properties[2];
                
$data['password'] = $properties[3];

                
// Load the users plugin group.
                
JPluginHelper::importPlugin('user');
                 
                
/* Set the values */
                
$user->groups = array(2);

                if (!
$user->bind($data))
                {
                    
$this->setError(JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED'$user->getError()));
                    return 
false;
                }
                 
                
/* Build the password */
                
$salt       JUserHelper::genRandomPassword(32);
                
$crypted    JUserHelper::getCryptedPasswordpreg_replace("/\s/"""strtolower($line[3])) , $salt);
                
$newpassword$crypted ':' $salt;
                 
                
$user->registerDate date('Y-m-d H:i:s');
                
                if (!
$user->save())
                {
                    
$this->setError(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED'$user->getError()));
                    return 
false;
                }
                else 
$added++;
            }

            if(
$added) return $added;
 
            
$this->setError(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED'"Ci sono stati degli errori nella importazione"));
            return 
false
        }
}


non so perché  funzioni solo con l’ultimo utente del csv
se ho questi 3 utenti

luca,luca,luca@alice.it,luca-->no
pippo,pippo@libero.com,pippo@outlook.com,ciao---->no
paolo,paolo@libero,paolo@libero.com,paolo2--> con questo utente fa il login corettamente
 
come mai???
« Ultima modifica: 22 Apr 2013, 15:37:09 da Marco31 »

pippo30

  • Visitatore
Re:Come Joomla registra password?????
« Risposta #10 il: 23 Apr 2013, 11:34:04 »
Codice: [Seleziona]

<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
 
// import Joomla controller library
jimport('joomla.application.component.controller');
 
/**
 * General Controller of JUserImporter component
 */
class JUserImporterController extends JControllerLegacy
{
        
/**
         * display task
         *
         * @return void
         */
        
function display($cachable false$urlparams = array()) 
        {
                
// set default view if not set
                
$input JFactory::getApplication()->input;
                
$input->set('view'$input->getCmd('view''JUserImporter'));
 
                
// call parent behavior
                
parent::display($cachable$urlparams);
        }
        
        
/**
         * Import task
         */
        
function importUsers($source "e:/xampp/htdocs/users2import.csv")
        {
            
/* Check the user file exists */
            /* Open the file */

            
if(!file_exists($source)) $source $_REQUEST['srcfile'];

            
$handle fopen($source,"r");
            
$content fread ($handle,filesize $source ));  
             
            
/* Get the file, line by line */
            
$lines explode("\n"$content);

            
fclose($handle); 
            
/* Counter of users added */
            
$added 0;
             
            
/* Iterate through each line of the data file */
            
for ($i 0$i count($lines); $i++){// as $key => $line){
                /* Split the line by comma */
                
$properties explode(",",$lines[$i]);

                
/* Build a new user object */
                
$user = new JUser();
                
$data = array();
                
$data['name'] = $properties[0];
                
$data['username'] = $properties[1];
                
$data['email'] = $properties[2];
                
$data['password'] = $properties[3];

                
// Load the users plugin group.
                
JPluginHelper::importPlugin('user');
                 
                
/* Set the values */
                
$user->groups = array(2);

                if (!
$user->bind($data))
                {
                    
$this->setError(JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED'$user->getError()));
                    return 
false;
                }
                 
                
$user->registerDate date('Y-m-d H:i:s');
                
                if (!
$user->save())
                {
                    
$this->setError(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED'$user->getError()));
                    return 
false;
                }
                else 
$added++;
                
$user null;
            }

            if(
$added) return $added;
 
            
$this->setError(JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED'"Ci sono stati degli errori nella importazione"));
            return 
false
        }
}



ho usato lo stesso metodo di joomla

Codice: [Seleziona]


/* Iterate through each line of the data file */
            for ($i = 0; $i < count($lines); $i++){// as $key => $line){
                /* Split the line by comma */
                $properties = explode(",",$lines[$i]


alla fine riga del csv una , e un carattere e funziona

 



Web Design Bolzano Kreatif