Visualizzazione dei risultati da 1 a 9 su 9
  1. #1

    Come reimpostare la password di un cms se non si dispone della shell di linux?

    Per reimpostare la password dell'amministratore di questo CMS:
    https://moodle.org/?lang=it
    bisogna digitare questo:
    codice:
    $ sudo -u apache / usr / bin / php admin / cli / reset_password.php
    peccato che io non disponga della shel di linux.
    Cosa mi invento?
    ciao e grazie
    Più pratica in futuro...

  2. #2
    Utente di HTML.it L'avatar di m4rko80
    Registrato dal
    Aug 2008
    residenza
    Milano
    Messaggi
    2,654
    In teoria basta eseguire quel file PHP. Dipende se accessibile lato web (spero di no).
    Senza riga di comando la vedo dura. Anche perchè viene eseguita come fosse apache (e quindi applicativo stesso) e non un utente qualsiasi. Con PHP per eseguire un file puoi usare:
    codice:
    php reset_password.php
    ma sempre da riga di comando.

  3. #3
    ma se ho installato il cms su un hosting condiviso dove scrivo il codice?
    non ho nessuna shell!
    l'unico supporto è filezilla
    ciao
    Più pratica in futuro...

  4. #4
    Utente di HTML.it L'avatar di m4rko80
    Registrato dal
    Aug 2008
    residenza
    Milano
    Messaggi
    2,654
    Questo reset password è un file di WP o è un file custom?
    Se non fa chissà che cosa (non conosco il suo contenuto) potresti eseguirlo da shell in locale modificando presumo le connessioni al Database dell'hosting piuttosto che a quello locale. Anche se avere un file del genere per cambiare una password non mi sembra molto sicuro averlo su di un sito in produzione.

  5. #5
    Quote Originariamente inviata da m4rko80 Visualizza il messaggio
    Questo reset password è un file di WP o è un file custom?
    non conosco la differenza!
    Più pratica in futuro...

  6. #6
    scusa, ho trovato il file, windows fa pietà... si trova in
    codice:
    \admin\cli\reset_password.php
    ma se lo scelgo come percorso nel browser ottengo:
    Command line scripts can not be executed from the web interface
    Più pratica in futuro...

  7. #7
    ecco il codice:
    codice:
    <?php
    
    // This file is part of Moodle - http://moodle.org/
    //
    // Moodle is free software: you can redistribute it and/or modify
    // it under the terms of the GNU General Public License as published by
    // the Free Software Foundation, either version 3 of the License, or
    // (at your option) any later version.
    //
    // Moodle is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.
    //
    // You should have received a copy of the GNU General Public License
    // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
    
    /**
     * This script allows you to reset any local user password.
     *
     * @package    core
     * @subpackage cli
     * @copyright  2009 Petr Skoda (http://skodak.org)
     * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
     */
    
    define('CLI_SCRIPT', true);
    
    require(__DIR__.'/../../config.php');
    require_once($CFG->libdir.'/clilib.php');      // cli only functions
    
    // Define the input options.
    $longparams = array(
            'help' => false,
            'username' => '',
            'password' => '',
            'ignore-password-policy' => false
    );
    
    $shortparams = array(
            'h' => 'help',
            'u' => 'username',
            'p' => 'password',
            'i' => 'ignore-password-policy'
    );
    
    // now get cli options
    list($options, $unrecognized) = cli_get_params($longparams, $shortparams);
    
    if ($unrecognized) {
        $unrecognized = implode("\n  ", $unrecognized);
        cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
    }
    
    if ($options['help']) {
        $help =
    "Reset local user passwords, useful especially for admin acounts.
    
    There are no security checks here because anybody who is able to
    execute this file may execute any PHP too.
    
    Options:
    -h, --help                    Print out this help
    -u, --username=username       Specify username to change
    -p, --password=newpassword    Specify new password
    --ignore-password-policy      Ignore password policy when setting password
    
    Example:
    \$sudo -u www-data /usr/bin/php admin/cli/reset_password.php
    \$sudo -u www-data /usr/bin/php admin/cli/reset_password.php --username=rosaura --password=jiu3jiu --ignore-password-policy
    ";
    
        echo $help;
        die;
    }
    if ($options['username'] == '' ) {
        cli_heading('Password reset');
        $prompt = "Enter username (manual authentication only)";
        $username = cli_input($prompt);
    } else {
        $username = $options['username'];
    }
    
    if (!$user = $DB->get_record('user', array('auth'=>'manual', 'username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
        cli_error("Can not find user '$username'");
    }
    
    if ($options['password'] == '' ) {
        $prompt = "Enter new password";
        $password = cli_input($prompt);
    } else {
        $password = $options['password'];
    }
    
    $errmsg = '';//prevent eclipse warning
    if (!$options['ignore-password-policy'] ) {
        if (!check_password_policy($password, $errmsg)) {
            cli_error(html_to_text($errmsg, 0));
        }
    }
    
    $hashedpassword = hash_internal_user_password($password);
    
    $DB->set_field('user', 'password', $hashedpassword, array('id'=>$user->id));
    
    echo "Password changed\n";
    
    exit(0); // 0 means success.
    Più pratica in futuro...

  8. #8
    Utente di HTML.it L'avatar di m4rko80
    Registrato dal
    Aug 2008
    residenza
    Milano
    Messaggi
    2,654
    Ad occhio e croce in require(__DIR__.'/../../config.php'); è presente la configurazione del DB e altro del CMS.
    Dovrestri provare da locale (presumo ora tu l'abbia testato da li) a creare una copia di config.php nella stessa posizione rinominando come ad esempio "config_prod.php" e modificare poi i dati contenuti in questo cambiando il puntamento del DB (con quello del servizio di hosting che di solito rilasciano).
    A questo punto se corretto potrai eseguirlo da locale senza necessità di farlo online. Ovviamente per eseguire per locale dovrai eseguire per locale:
    codice:
    require(__DIR__.'/../../config.php');
    per produzione
    codice:
    require(__DIR__.'/../../config_prod.php');

  9. #9
    ecco il codice di config-dist.php:
    codice:
    $CFG->dbtype    = 'pgsql';      // 'pgsql', 'mariadb', 'mysqli', 'sqlsrv' or 'oci'
    $CFG->dblibrary = 'native';     // 'native' only at the moment
    $CFG->dbhost    = 'localhost';  // eg 'localhost' or 'db.isp.com' or IP
    $CFG->dbname    = 'moodle';     // database name, eg moodle
    $CFG->dbuser    = 'username';   // your database username
    $CFG->dbpass    = 'password';   // your database password
    $CFG->prefix    = 'mdl_';       // prefix to use for all table names
    $CFG->dboptions = array(
        'dbpersist' => false,       // should persistent database connections be
                                    //  used? set to 'false' for the most stable
                                    //  setting, 'true' can improve performance
                                    //  sometimes
        'dbsocket'  => false,       // should connection via UNIX socket be used?
                                    //  if you set it to 'true' or custom path
                                    //  here set dbhost to 'localhost',
                                    //  (please note mysql is always using socket
                                    //  if dbhost is 'localhost' - if you need
                                    //  local port connection use '127.0.0.1')
        'dbport'    => '',          // the TCP port number to use when connecting
                                    //  to the server. keep empty string for the
                                    //  default port
        'dbhandlesoptions' => false,// On PostgreSQL poolers like pgbouncer don't
                                    // support advanced options on connection.
                                    // If you set those in the database then
                                    // the advanced settings will not be sent.
        'dbcollation' => 'utf8mb4_unicode_ci', // MySQL has partial and full UTF-8
                                    // support. If you wish to use partial UTF-8
                                    // (three bytes) then set this option to
                                    // 'utf8_unicode_ci', otherwise this option
                                    // can be removed for MySQL (by default it will
                                    // use 'utf8mb4_unicode_ci'. This option should
                                    // be removed for all other databases.
        // 'fetchbuffersize' => 100000, // On PostgreSQL, this option sets a limit
                                    // on the number of rows that are fetched into
                                    // memory when doing a large recordset query
                                    // (e.g. search indexing). Default is 100000.
                                    // Uncomment and set to a value to change it,
                                    // or zero to turn off the limit. You need to
                                    // set to zero if you are using pg_bouncer in
                                    // 'transaction' mode (it is fine in 'session'
                                    // mode).
    );
    Più pratica in futuro...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.