Example #1
0
 /** Hook function called when a user is created.
  * AlternC's standard function that create a member
  * @access private
  */
 function alternc_add_member()
 {
     global $db, $err, $cuid, $mem;
     $err->log("mysql", "alternc_add_member");
     //checking for the phpmyadmin user
     $db->query("SELECT name,password FROM dbusers WHERE uid={$cuid} AND Type='ADMIN';");
     if ($db->num_rows()) {
         $myadm = $db->f("name");
         $password = $db->f("password");
     } else {
         $myadm = $cuid . "_myadm";
         $password = create_pass(8);
     }
     $db->query("INSERT INTO dbusers (uid,name,password,enable) VALUES ('{$cuid}','{$myadm}','{$password}','ADMIN');");
     return true;
 }
Example #2
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
$app = (require_once __DIR__ . '/../app/app.php');
$passes = [];
$h = fopen(__DIR__ . '/passes.csv', "w");
while ($user = fgetcsv(STDIN, ";")) {
    $id = $user[0];
    $lastName = $user[1];
    $firstName = $user[2];
    $class = $user[3];
    $companyID = isset($user[4]) ? $user[4] : NULL;
    $pass = create_pass();
    $passes = [$lastName, $firstName, $class, $pass];
    $roles = $companyID !== NULL ? 'betriebsleiter' : '';
    $isChief = $companyID == NULL ? false : true;
    $chiefOf_ID = $companyID;
    insert_user($id, $firstName, $lastName, password_hash($pass, PASSWORD_DEFAULT), $roles, $isChief, $chiefOf_ID, $app['db.connection']);
    fputcsv($h, $passes, ";");
}
function create_pass($length = 6)
{
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, strlen($characters) - 1)];
    }
    return $randomString;
}
function insert_user($id, $firstName, $lastName, $pass, $roles, $isChief, $chiefOf_ID, $c)
{
Example #3
0
                $h = fopen($www_local_htaccess, "x+");
                fwrite($h, $str);
                fclose($h);
                echo '<p>Created .htaccess file to support the www/local directory</p>';
            }
        }
    }
    $mybuf = ob_get_contents();
    ob_end_clean();
    if (isset($alarm) && $alarm) {
        echo '<p class="error">Warning: The .htaccess setup for the local version of your www folder may be improperly setup</p>';
    }
    echo $mybuf;
}
if (admin_user_exists() == false) {
    $password = create_pass();
    $password_hash = sha1($password);
    $user_id = create_admin_user($password);
    if ($user_id > 0) {
        // create the page types demo site if running the first time (i.e. there is no admin user)
        reason_include_once('function_libraries/admin_actions.php');
        reason_include_once('classes/entity_selector.php');
        $ptds_id = id_of('page_types_demo_site');
        $ptds_entity = new entity($ptds_id);
        $path = WEB_PATH . trim_slashes($ptds_entity->get_value('base_url'));
        echo '<h3>Checking for Page Types Demo site</h3>';
        if (!is_dir($path)) {
            echo '<p>Creating demo site</p>';
            reason_include_once('classes/url_manager.php');
            include_once CARL_UTIL_INC . 'basic/filesystem.php';
            mkdir_recursive($path, 0775);
        $i++;
    }
    return $password;
}
mysql_connect($mhost, $muser, $mpass);
mysql_select_db($mdb);
mysql_query("UPDATE dbusers SET enable='ACTIVATED' WHERE name!=CONCAT(uid,'_myadm');");
$r = mysql_query("SELECT uid, login FROM membres;");
while ($c = mysql_fetch_array($r)) {
    $membres[$c["uid"]] = $c["login"];
}
foreach ($membres as $uid => $membre) {
    $ok = @mysql_fetch_array(mysql_query("SELECT * FROM dbusers WHERE uid={$uid} AND NAME='" . $uid . "_myadm';"));
    if (!$ok) {
        echo "Creating user " . $uid . "_myadm for login " . $membre . "\n";
        $pass = create_pass(8);
        mysql_query("INSERT INTO dbusers SET uid={$uid}, name='" . $uid . "_myadm', password='******', enable='ADMIN';");
        echo mysql_error();
    } else {
        $pass = $ok["password"];
    }
    echo "Granting rights to user " . $uid . "_myadm for login " . $membre . " ... ";
    // Now granting him access to all user's databases
    mysql_query("GRANT USAGE ON *.* TO '" . $uid . "_myadm'@localhost IDENTIFIED BY '{$pass}';");
    echo mysql_error();
    $t = mysql_query("SELECT * FROM db WHERE uid={$uid};");
    echo mysql_error();
    while ($d = mysql_fetch_array($t)) {
        mysql_query("GRANT ALL ON " . $d["db"] . ".* TO '" . $uid . "_myadm'@localhost;");
        echo " " . $d["db"];
        echo mysql_error();
Example #5
0
 function user_add($user_login, $user_mail = null)
 {
     global $db, $mem, $cuid, $err;
     $user_login = $this->clean_user_name($user_login);
     $user_pass = create_pass();
     $user_mail = $mem->user['mail'];
     $user_alias = $user_login;
     $api_data = $this->call_privileged_page('API', 'UsersManager.addUser', array('userLogin' => $user_login, 'password' => $user_pass, 'email' => $user_mail, 'alias' => $user_alias), 'JSON');
     if ($api_data) {
         if ($api_data->result === 'success') {
             $user = $this->get_user($user_login);
             $user_creation_date = $user->date_registered;
             return $db->query("INSERT INTO piwik_users (uid, login, created_date) VALUES ('{$cuid}', '{$user_login}', '{$user_creation_date}')");
         } else {
             $err->raise('piwik', $api_data->message);
             return FALSE;
         }
     } else {
         // api_data = false -> error is already filled
         return FALSE;
     }
 }
Example #6
0
     $nb_res = sql_num_rows($res);
     $ligne_email = sql_fetch_array($res);
     sql_free_result($res);
     sql_close($sgbd);
     if ($nb_res != "1") {
         $page['erreur'][$nb_erreur]['message'] = $lang['member']['E_absent_email'];
         $nb_erreur++;
     }
 }
 if (isset($ligne_login['member_id']) and isset($ligne_email['member_id']) and $ligne_login['member_id'] != $ligne_email['member_id']) {
     $page['erreur'][$nb_erreur]['message'] = $lang['member']['E_absent_email'];
     $nb_erreur++;
 }
 if ($nb_erreur == 0) {
     # we create a new password, we save it and send it by email
     $_POST['pass'] = create_pass();
     $_POST['pass_md5'] = md5($_POST['pass']);
     $_POST['id'] = $ligne_login['member_id'];
     $page['show_form'] = '';
     $sql_modif = sql_replace($sql['member']['edit_member_pass'], $_POST);
     $sgbd = sql_connect();
     $execution = sql_query($sql_modif);
     if ($execution) {
         $var['firstname'] = $_POST['login'];
         $var['site_title'] = SITE_TITLE;
         $var['site_url'] = ROOT_URL;
         $var['sender_email'] = SENDER_EMAIL;
         $var['sender_name'] = SENDER_NAME;
         $var['login'] = $_POST['login'];
         $var['pass'] = $_POST['pass'];
         $message = text_replace($lang['member']['mail_forgot_pass_message'], $var);