function generate()
 {
     global $Language;
     $request =& HTTPRequest::instance();
     if ($data = $request->get('data')) {
         if (isset($data['users']['generate']) && $data['users']['generate']) {
             $um = UserManager::instance();
             $nb_wanted = isset($data['users']['nb']) ? (int) $data['users']['nb'] : 1;
             $users = $this->_getUsersData();
             reset($users);
             $nb_done = 0;
             while ((list(, $user) = each($users)) && $nb_wanted > $nb_done) {
                 if (!$um->getUserByUserName($user['name'])) {
                     require_once 'account.php';
                     account_create($user['name'], 'codendi', '', $user['realname'], '', '*****@*****.**', 'A', '', 0, 0, 'Europe/Paris', 'en_US', 'A');
                     $nb_done++;
                 }
             }
         }
         if (isset($data['projects']['generate']) && $data['projects']['generate']) {
             $nb_wanted = isset($data['projects']['nb']) ? (int) $data['projects']['nb'] : 1;
             $projects = $this->_getProjectsData();
             reset($projects);
             $nb_done = 0;
             while ((list(, $project) = each($projects)) && $nb_wanted > $nb_done) {
                 if (!group_get_object_by_name($project['name'])) {
                     $projectCreator = new ProjectCreator(ProjectManager::instance(), ReferenceManager::instance());
                     $projectCreator->create(array('project' => array('form_unix_name' => $project['name'], 'form_full_name' => $project['name'], 'form_short_description' => $project['description'], 'form_purpose' => $project['description'], 'form_required_sw' => '', 'form_patents' => '', 'form_comments' => '', 'built_from_template' => 100, 'is_test' => false, 'is_public' => true, 'trove' => array())));
                     $nb_done++;
                 }
             }
         }
     }
 }
Beispiel #2
0
function uni_create($uniAccount, $account = array())
{
    global $_W;
    load()->model('module');
    if (isset($uniAccount['groupdata'])) {
        $unisettings['groupdata'] = $uniAccount['groupdata'];
        unset($uniAccount['groupdata']);
    }
    if ($_W['isfounder'] && isset($uniAccount['notify'])) {
        $unisettings['notify'] = $uniAccount['notify'];
        unset($uniAccount['notify']);
    } else {
        unset($uniAccount['notify']);
    }
    $unisettings['bootstrap'] = $uniAccount['bootstrap'];
    unset($uniAccount['bootstrap']);
    pdo_insert('uni_account', $uniAccount);
    $uniacid = pdo_insertid();
    $template = pdo_fetch('SELECT id,title FROM ' . tablename('site_templates') . " WHERE name = 'default'");
    $styles['uniacid'] = $uniacid;
    $styles['templateid'] = $template['id'];
    $styles['name'] = $template['title'] . '_' . random(4);
    pdo_insert('site_styles', $styles);
    $styleid = pdo_insertid();
    $multi['uniacid'] = $uniacid;
    $multi['title'] = $uniAccount['name'];
    $multi['quickmenu'] = iserializer(array('template' => 'default', 'enablemodule' => array()));
    $multi['styleid'] = $styleid;
    pdo_insert('site_multi', $multi);
    $multi_id = pdo_insertid();
    $unisettings['uniacid'] = $uniacid;
    $unisettings['default_site'] = $multi_id;
    $unisettings['creditnames'] = array('credit1' => array('title' => '积分', 'enabled' => 1), 'credit2' => array('title' => '余额', 'enabled' => 1));
    $unisettings['creditnames'] = iserializer($unisettings['creditnames']);
    $unisettings['creditbehaviors'] = array('activity' => 'credit1', 'currency' => 'credit2');
    $unisettings['creditbehaviors'] = iserializer($unisettings['creditbehaviors']);
    pdo_insert('uni_settings', $unisettings);
    pdo_insert('mc_groups', array('uniacid' => $uniacid, 'title' => '默认会员组', 'isdefault' => 1));
    $account_users = array('uniacid' => $uniacid, 'uid' => $_W['uid'], 'role' => 'manager');
    pdo_insert('uni_account_users', $account_users);
    module_build_privileges();
    if (!$uniacid) {
        return error('-1', '添加公众号基本信息失败');
    }
    if (!empty($account)) {
        $acid = account_create($uniacid, $account);
        if (!$acid) {
            return error('-1', '添加公众号信息失败');
        }
        return array('acid' => $acid, 'uniacid' => $uniacid);
    }
    return $uniacid;
}
Beispiel #3
0
 $unisettings['creditbehaviors'] = iserializer($unisettings['creditbehaviors']);
 $unisettings['uniacid'] = $uniacid;
 $unisettings['default_site'] = $multi_id;
 $unisettings['sync'] = iserializer(array('switch' => 0, 'acid' => ''));
 pdo_insert('uni_settings', $unisettings);
 pdo_insert('mc_groups', array('uniacid' => $uniacid, 'title' => '默认会员组', 'isdefault' => 1));
 $account_users = array('uniacid' => $uniacid, 'uid' => 1, 'role' => 'manager');
 pdo_insert('uni_account_users', $account_users);
 load()->model('module');
 module_build_privileges();
 $insert['account'] = trim($_GPC['account']);
 $insert['name'] = trim($_GPC['name']);
 $insert['level'] = 1;
 $insert['type'] = 1;
 if (empty($account)) {
     $acid = account_create($uniacid, $insert);
     if (!empty($_FILES['qrcode']['tmp_name'])) {
         $_W['uploadsetting'] = array();
         $_W['uploadsetting']['image']['folder'] = $acid;
         //file be save in attachment/$acid
         $_W['uploadsetting']['image']['extentions'] = array('jpg', 'jpeg', 'png');
         $_W['uploadsetting']['image']['limit'] = $_W['config']['upload']['image']['limit'];
         $upload = file_upload($_FILES['qrcode'], 'image', "qrcode_{$acid}");
     }
     if (!empty($_FILES['headimg']['tmp_name'])) {
         $_W['uploadsetting'] = array();
         $_W['uploadsetting']['image']['folder'] = $acid;
         //file be save in attachment/$acid
         $_W['uploadsetting']['image']['extentions'] = array('jpg', 'jpeg', 'png');
         $_W['uploadsetting']['image']['limit'] = $_W['config']['upload']['image']['limit'];
         $upload = file_upload($_FILES['headimg'], 'image', "headimg_{$acid}");
Beispiel #4
0
     pdo_insert('mc_groups', array('uniacid' => $uniacid, 'title' => '默认会员组', 'isdefault' => 1));
     $account_users = array('uniacid' => $uniacid, 'uid' => $_W['uid'], 'role' => 'manager');
     pdo_insert('uni_account_users', $account_users);
     load()->model('module');
     module_build_privileges();
 }
 load()->func('file');
 $update['account'] = trim($_GPC['account']);
 $update['original'] = trim($_GPC['original']);
 $update['level'] = intval($_GPC['level']);
 $update['key'] = trim($_GPC['key']);
 $update['secret'] = trim($_GPC['secret']);
 $update['type'] = intval($_GPC['type']);
 $update['encodingaeskey'] = trim($_GPC['encodingaeskey']);
 if (empty($account)) {
     $acid = account_create($uniacid, $update);
     if (is_error($acid)) {
         message('添加公众号信息失败', '', url('account/post-step/', array('uniacid' => intval($_GPC['uniacid']), 'step' => 3), 'error'));
     }
     $oauth = uni_setting($uniacid, array('oauth'));
     if ($acid && !empty($update['key']) && !empty($update['secret']) && empty($oauth['oauth']['account']) && $update['level'] == 4) {
         pdo_update('uni_settings', array('oauth' => iserializer(array('status' => 1, 'account' => $acid))), array('uniacid' => $uniacid));
     }
     if (!empty($_FILES['qrcode']['tmp_name'])) {
         $_W['uploadsetting'] = array();
         $_W['uploadsetting']['image']['folder'] = '';
         $_W['uploadsetting']['image']['extentions'] = array('jpg');
         $_W['uploadsetting']['image']['limit'] = $_W['config']['upload']['image']['limit'];
         $upload = file_upload($_FILES['qrcode'], 'image', "qrcode_{$acid}");
     }
     if (!empty($_FILES['headimg']['tmp_name'])) {
Beispiel #5
0
function register_valid($confirm_hash)
{
    global $Language;
    $request =& HTTPRequest::instance();
    $vLoginName = new Valid_UserNameFormat('form_loginname');
    $vLoginName->required();
    if (!$request->valid($vLoginName)) {
        return 0;
    }
    $vRealName = new Valid_RealNameFormat('form_realname');
    $vRealName->required();
    if (!$request->valid($vRealName)) {
        $GLOBALS['Response']->addFeedback('error', $Language->getText('account_register', 'err_realname'));
        return 0;
    }
    if (!$request->existAndNonEmpty('form_pw')) {
        $GLOBALS['Response']->addFeedback('error', $Language->getText('account_register', 'err_nopasswd'));
        return 0;
    }
    $tz = $request->get('timezone');
    if (!is_valid_timezone($tz)) {
        $GLOBALS['Response']->addFeedback('error', $Language->getText('account_register', 'err_notz'));
        return 0;
    }
    if (!$request->existAndNonEmpty('form_register_purpose') && ($GLOBALS['sys_user_approval'] && $request->get('page') != "admin_creation")) {
        $GLOBALS['Response']->addFeedback('error', $Language->getText('account_register', 'err_nopurpose'));
        return 0;
    }
    if (!validate_email($request->get('form_email'))) {
        $GLOBALS['Response']->addFeedback('error', $Language->getText('account_register', 'err_email'));
        return 0;
    }
    if ($request->get('page') != "admin_creation" && $request->get('form_pw') != $request->get('form_pw2')) {
        $GLOBALS['Response']->addFeedback('error', $Language->getText('account_register', 'err_passwd'));
        return 0;
    }
    if (!account_pwvalid($request->get('form_pw'), $errors)) {
        foreach ($errors as $e) {
            $GLOBALS['Response']->addFeedback('error', $e);
        }
        return 0;
    }
    $expiry_date = 0;
    if ($request->exist('form_expiry') && $request->get('form_expiry') != '' && !ereg("[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}", $request->get('form_expiry'))) {
        $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('account_register', 'data_not_parsed'));
        return 0;
    }
    $vDate = new Valid_String();
    $vDate->required();
    if ($request->exist('form_expiry') && $vDate->validate($request->get('form_expiry'))) {
        $date_list = split("-", $request->get('form_expiry'), 3);
        $unix_expiry_time = mktime(0, 0, 0, $date_list[1], $date_list[2], $date_list[0]);
        $expiry_date = $unix_expiry_time;
    }
    $status = 'P';
    if ($request->get('page') == "admin_creation") {
        if ($request->get('form_restricted')) {
            $status = 'R';
        } else {
            $status = 'A';
        }
    }
    //use sys_lang as default language for each user at register
    $res = account_create($request->get('form_loginname'), $request->get('form_pw'), '', $request->get('form_realname'), $request->get('form_register_purpose'), $request->get('form_email'), $status, $confirm_hash, $request->get('form_mail_site'), $request->get('form_mail_va'), $tz, UserManager::instance()->getCurrentUser()->getLocale(), 'A', $expiry_date);
    return $res;
}
Beispiel #6
0
        redirect();
    } else {
        redirect('/login?error=Incorrect email or password');
    }
});
get('/register', function () {
    render('register', array('head_title' => 'Register'));
});
post('/register', function () {
    $username = from($_REQUEST, 'username');
    $email = from($_REQUEST, 'email');
    $password = from($_REQUEST, 'password');
    if (account_exists($email)) {
        redirect('/register?error=Account already exists');
    }
    account_create($email, $username, $password);
    redirect('/login?success=Account created, you can now login');
});
get('/logout', function () {
    destroy_session();
    redirect();
});
get('/regenerate', function () {
    if (logged_in()) {
        create_session(user_email());
    }
    redirect();
});
// Apply
// --------------------------------------------------------------------------------
get('/apply', function () {
Beispiel #7
0
function account_create_submit($userid, $email)
{
    global $theme, $site_name, $site_url;
    $new[userid] = trim($userid);
    $new[real_email] = trim($email);
    if ($error = account_validate($new)) {
        $theme->header();
        $theme->box(t("Create user account"), account_create($error));
        $theme->footer();
    } else {
        $new[passwd] = account_password();
        $new[hash] = substr(md5("{$new['userid']}. " . time()), 0, 12);
        $user = user_save("", array("userid" => $new[userid], "real_email" => $new[real_email], "passwd" => $new[passwd], "status" => 1, "hash" => $new[hash]));
        $link = $site_url . "account.php?op=confirm&name={$new['userid']}&hash={$new['hash']}";
        $subject = strtr(t("Account details for %a"), array("%a" => $site_name));
        $message = strtr(t("%a,\n\n\nsomeone signed up for a user account on %b and supplied this e-mail address as their contact.  If it wasn't you, don't get your panties in a knot and simply ignore this mail.  If this was you, you will have to confirm your account first or you will not be able to login.  To confirm your account visit the URL below:\n\n   %c\n\nOnce confirmed you can login using the following username and password:\n\n   username: %a\n   password: %d\n\n\n-- %b team\n"), array("%a" => $new[userid], "%b" => $site_name, "%c" => $link, "%d" => $new[passwd]));
        watchdog("message", "new account: `{$new['userid']}' <{$new['real_email']}>");
        mail($new[real_email], $subject, $message, "From: noreply");
        $theme->header();
        $theme->box(t("Create user account"), t("Congratulations!  Your member account has been successfully created and further instructions on how to confirm your account have been sent to your e-mail address.  You have to confirm your account first or you will not be able to login."));
        $theme->footer();
    }
}
Beispiel #8
0
         $account['secret'] = $basicinfo['secret'];
         $account['type'] = intval($_GPC['type']);
     }
 } else {
     if (empty($_GPC['name'])) {
         message('抱歉,名称和楼盘项目账号为必填项请返回填写!');
     }
     $account['name'] = $_GPC['name'];
     $account['account'] = $_GPC['account'];
     $account['level'] = intval($_GPC['level']);
     $account['key'] = $_GPC['key'];
     $account['secret'] = $_GPC['secret'];
     $account['type'] = intval($_GPC['type']);
 }
 if (empty($acid)) {
     $acid = account_create($uniacid, $account);
 } else {
     $account['token'] = $_GPC['wetoken'];
     unset($account['type']);
     pdo_update($tablename, $account, array('acid' => $acid, 'uniacid' => $uniacid));
 }
 if ($_GPC['model'] == 2) {
     if (!empty($basicinfo['headimg'])) {
         file_write('headimg_' . $acid . '.jpg', $basicinfo['headimg']);
     }
     if (!empty($basicinfo['qrcode'])) {
         file_write('qrcode_' . $acid . '.jpg', $basicinfo['qrcode']);
     }
     if (!empty($loginstatus)) {
         if ($type == 'wechat') {
             $result = account_weixin_interface($data['username'], $data['hash'], $data['token']);
Beispiel #9
0
    $account['passwd'] = hash('whirlpool', $passwd);
    $account['admin'] = 0;
    $db[] = $account;
    file_put_contents('../private/passwd', serialize($db));
    return true;
}
if (!$_SESSION['log_on_user']) {
    if ($_POST['submit'] == 'CREATE') {
        if (!filter_var($_POST['mail'], FILTER_VALIDATE_EMAIL)) {
            $_POST['mail'] = "'Invalid Mail'";
        }
        if ($_POST['mail'] && $_POST['passwd'] && $_POST['vpasswd']) {
            if ($_POST['passwd'] == $_POST['vpasswd']) {
                check_passwd_path();
                if (filter_var($_POST['mail'], FILTER_VALIDATE_EMAIL)) {
                    if (account_create($_POST['mail'], $_POST['passwd']) === true) {
                        var_dump($_POST);
                        $_SESSION['log_on_user'] = $_POST['mail'];
                        header("Location: index.php");
                    }
                } else {
                    $_POST['mail'] = "'Invalid Mail'";
                }
            }
        } else {
            $_POST['mail'] = $_POST['mail'];
            $_POST['passwd'] = $_POST['passwd'];
        }
    } else {
        $_POST['vpasswd'] = "'Password not same'";
    }