• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_random_key函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_random_key函数的典型用法代码示例。如果您正苦于以下问题:PHP get_random_key函数的具体用法?PHP get_random_key怎么用?PHP get_random_key使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_random_key函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: forgotpass_submit

function forgotpass_submit(Pieform $form, $values)
{
    global $SESSION;
    try {
        if (!($user = get_record_sql('SELECT * FROM {usr} WHERE LOWER(email) = ?', array(strtolower($values['emailusername']))))) {
            if (!($user = get_record_sql('SELECT * FROM {usr} WHERE LOWER(username) = ?', array(strtolower($values['emailusername']))))) {
                die_info(get_string('forgotpassnosuchemailaddressorusername'));
            }
        }
        $pwrequest = new StdClass();
        $pwrequest->usr = $user->id;
        $pwrequest->expiry = db_format_timestamp(time() + 86400);
        $pwrequest->key = get_random_key();
        $sitename = get_config('sitename');
        $fullname = display_name($user);
        email_user($user, null, get_string('forgotusernamepasswordemailsubject', 'mahara', $sitename), get_string('forgotusernamepasswordemailmessagetext', 'mahara', $fullname, $sitename, $user->username, get_config('wwwroot') . 'forgotpass.php?key=' . $pwrequest->key, get_config('wwwroot') . 'contact.php', $sitename), get_string('forgotusernamepasswordemailmessagehtml', 'mahara', $fullname, $sitename, $user->username, get_config('wwwroot') . 'forgotpass.php?key=' . $pwrequest->key, get_config('wwwroot') . 'forgotpass.php?key=' . $pwrequest->key, get_config('wwwroot') . 'contact.php', $sitename));
        insert_record('usr_password_request', $pwrequest);
    } catch (SQLException $e) {
        die_info(get_string('forgotpassemailsendunsuccessful'));
    } catch (EmailException $e) {
        die_info(get_string('forgotpassemailsendunsuccessful'));
    }
    // Add a marker in the session to say that the user has registered
    $_SESSION['pwchangerequested'] = true;
    redirect('/forgotpass.php');
}
开发者ID:Br3nda,项目名称:mahara,代码行数:26,代码来源:forgotpass.php


示例2: __construct

 /**
  * constructor.  overrides the parent class
  * to set up smarty and the attachment directory
  */
 public function __construct(User $user, $views, $artefacts, $progresshandler = null)
 {
     parent::__construct($user, $views, $artefacts, $progresshandler);
     $this->smarty = smarty_core();
     if (!check_dir_exists($this->exportdir . '/' . $this->filedir)) {
         throw new SystemException("Couldn't create the temporary export directory {$this->exportdir}");
     }
     $this->zipfile = 'mahara-export-leap-user' . $this->get('user')->get('id') . '-' . date('Y-m-d_H-i', $this->exporttime) . '_' . get_random_key() . '.zip';
     // some plugins might want to do their own special thing
     foreach (plugins_installed('artefact', true) as $plugin) {
         $plugin = $plugin->name;
         if (safe_require('export', 'leap/' . $plugin, 'lib.php', 'require_once', true)) {
             $classname = 'LeapExport' . ucfirst($plugin);
             if (class_exists($classname) && call_static_method($classname, 'override_entire_export')) {
                 $this->specialcases[$plugin] = array();
             }
         }
     }
     $outputfilter = LeapExportOutputFilter::singleton();
     $outputfilter->set_artefactids(array_keys($this->artefacts));
     $this->notify_progress_callback(5, get_string('setupcomplete', 'export'));
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:26,代码来源:lib.php


示例3: set_antispam_defaults

/**
 * Use meaningful defaults for the antispam settings.
 */
function set_antispam_defaults()
{
    set_config('formsecret', get_random_key());
    require_once get_config('docroot') . 'lib/antispam.php';
    if (checkdnsrr('test.uribl.com.black.uribl.com', 'A')) {
        set_config('antispam', 'advanced');
    } else {
        set_config('antispam', 'simple');
    }
    set_config('spamhaus', 0);
    set_config('surbl', 0);
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:15,代码来源:upgrade.php


示例4: xmldb_core_upgrade


//.........这里部分代码省略.........
    if ($oldversion < 2009021700) {
        reload_html_filters();
    }
    if ($oldversion < 2009021701) {
        // Make sure that all views that can be copied have loggedin access
        // This upgrade just fixes potentially corrupt data caused by running a
        // beta version then upgrading it
        if ($views = get_column('view', 'id', 'copynewuser', '1')) {
            $views[] = 1;
            require_once 'view.php';
            foreach ($views as $viewid) {
                $view = new View($viewid);
                $needsadding = true;
                foreach ($view->get_access() as $item) {
                    if ($item['type'] == 'loggedin') {
                        // We're not checking that access dates are null (aka
                        // it can always be accessed), but the chance of people
                        // needing this upgrade are slim anyway
                        $needsadding = false;
                        break;
                    }
                }
                if ($needsadding) {
                    log_debug("Adding logged in access for view {$viewid}");
                    $access = $view->get_access();
                    $access[] = array('type' => 'loggedin', 'startdate' => null, 'stopdate' => null);
                    $view->set_access($access);
                }
            }
        }
    }
    if ($oldversion < 2009021900) {
        // Generate a unique installation key
        set_config('installation_key', get_random_key());
    }
    if ($oldversion < 2009021901) {
        // Insert a cron job to send registration data to mahara.org
        $cron = new StdClass();
        $cron->callfunction = 'cron_send_registration_data';
        $cron->minute = rand(0, 59);
        $cron->hour = rand(0, 23);
        $cron->day = '*';
        $cron->month = '*';
        $cron->dayofweek = rand(0, 6);
        insert_record('cron', $cron);
    }
    if ($oldversion < 2009022700) {
        // Get rid of all blocks with position 0 caused by 'about me' block on profile views
        if (count_records('block_instance', 'order', 0) && !count_records_select('block_instance', '"order" < 0')) {
            if (is_mysql()) {
                $ids = get_column_sql('
                    SELECT i.id FROM {block_instance} i
                    INNER JOIN (SELECT view, "column" FROM {block_instance} WHERE "order" = 0) z
                        ON (z.view = i.view AND z.column = i.column)');
                execute_sql('UPDATE {block_instance} SET "order" =  -1 * "order" WHERE id IN (' . join(',', $ids) . ')');
            } else {
                execute_sql('UPDATE {block_instance} SET "order" =  -1 * "order" WHERE id IN (
                    SELECT i.id FROM {block_instance} i
                    INNER JOIN (SELECT view, "column" FROM {block_instance} WHERE "order" = 0) z
                        ON (z.view = i.view AND z.column = i.column))');
            }
            execute_sql('UPDATE {block_instance} SET "order" = 1 WHERE "order" = 0');
            execute_sql('UPDATE {block_instance} SET "order" = -1 * ("order" - 1) WHERE "order" < 0');
        }
    }
    if ($oldversion < 2009031000) {
开发者ID:Br3nda,项目名称:mahara,代码行数:67,代码来源:upgrade.php


示例5: auth_register_submit

function auth_register_submit(Pieform $form, $values)
{
    global $SESSION;
    safe_require('auth', 'internal');
    $values['key'] = get_random_key();
    $values['lang'] = $SESSION->get('lang');
    // If the institution requires approval, mark the record as pending
    // @todo the expiry date should be configurable
    if ($confirm = get_config('requireregistrationconfirm') || get_field('institution', 'registerconfirm', 'name', $values['institution'])) {
        if (isset($values['authtype']) && $values['authtype'] != 'internal') {
            $authinstance = get_record('auth_instance', 'institution', $values['institution'], 'authname', $values['authtype'] ? $values['authtype'] : 'internal');
            $auth = AuthFactory::create($authinstance->id);
            $confirm = !$auth->weautocreateusers;
        }
        if ($confirm) {
            $values['pending'] = 1;
            $values['expiry'] = db_format_timestamp(time() + 86400 * 14);
            // now + 2 weeks
        } else {
            $values['pending'] = 0;
            $values['expiry'] = db_format_timestamp(time() + 86400);
        }
    } else {
        $values['pending'] = 0;
        $values['expiry'] = db_format_timestamp(time() + 86400);
    }
    if (function_exists('local_register_submit')) {
        local_register_submit($values);
    }
    try {
        if (!record_exists('usr_registration', 'email', $values['email'])) {
            insert_record('usr_registration', $values);
        } else {
            update_record('usr_registration', $values, array('email' => $values['email']));
        }
        $user = (object) $values;
        $user->admin = 0;
        $user->staff = 0;
        // If the institution requires approval, notify institutional admins.
        if ($confirm) {
            $fullname = sprintf("%s %s", trim($user->firstname), trim($user->lastname));
            $institution = new Institution($values['institution']);
            $pendingregistrationslink = sprintf("%sadmin/users/pendingregistrations.php?institution=%s", get_config('wwwroot'), $values['institution']);
            // list of admins for this institution
            if (count($institution->admins()) > 0) {
                $admins = $institution->admins();
            } else {
                // use site admins if the institution doesn't have any
                $admins = get_column('usr', 'id', 'admin', 1, 'deleted', 0);
            }
            require_once get_config('libroot') . 'pieforms/pieform/elements/expiry.php';
            $expirytime = pieform_element_expiry_get_expiry_from_seconds(get_config('defaultregistrationexpirylifetime'));
            if ($expirytime == null) {
                $expirystring = get_config('defaultregistrationexpirylifetime') . ' ' . get_string('seconds', 'performance');
            } else {
                if ($expirytime['units'] == 'noenddate') {
                    $expirystring = get_string('element.expiry.noenddate', 'pieforms');
                } else {
                    $expirystring = $expirytime['number'] . ' ' . get_string('element.expiry.' . $expirytime['units'], 'pieforms');
                }
            }
            // email each admin
            // @TODO Respect the notification preferences of the admins.
            foreach ($admins as $admin) {
                $adminuser = new User();
                $adminuser->find_by_id($admin);
                email_user($adminuser, null, get_string('pendingregistrationadminemailsubject', 'auth.internal', $institution->displayname, get_config('sitename')), get_string('pendingregistrationadminemailtext', 'auth.internal', $adminuser->firstname, $institution->displayname, $pendingregistrationslink, $expirystring, $fullname, $values['email'], $values['reason'], get_config('sitename')), get_string('pendingregistrationadminemailhtml', 'auth.internal', $adminuser->firstname, $institution->displayname, $pendingregistrationslink, $pendingregistrationslink, $expirystring, $fullname, $values['email'], $values['reason'], get_config('sitename')));
            }
            email_user($user, null, get_string('approvalemailsubject', 'auth.internal', get_config('sitename')), get_string('approvalemailmessagetext', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('sitename')), get_string('approvalemailmessagehtml', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('sitename')));
            $_SESSION['registeredokawaiting'] = true;
        } else {
            if (isset($values['authtype']) && $values['authtype'] == 'browserid') {
                redirect('/register.php?key=' . $values['key']);
            } else {
                email_user($user, null, get_string('registeredemailsubject', 'auth.internal', get_config('sitename')), get_string('registeredemailmessagetext', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('wwwroot'), $values['key'], get_config('sitename')), get_string('registeredemailmessagehtml', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('wwwroot'), $values['key'], get_config('wwwroot'), $values['key'], get_config('sitename')));
            }
            // Add a marker in the session to say that the user has registered
            $_SESSION['registered'] = true;
        }
    } catch (EmailException $e) {
        log_warn($e);
        die_info(get_string('registrationunsuccessful', 'auth.internal'));
    } catch (SQLException $e) {
        log_warn($e);
        die_info(get_string('registrationunsuccessful', 'auth.internal'));
    }
    redirect($values['goto']);
}
开发者ID:janaece,项目名称:globalclassroom4_clean-old,代码行数:88,代码来源:lib.php


示例6: xmldb_core_upgrade


//.........这里部分代码省略.........
        $table = new XMLDBTable('view');
        $field = new XMLDBField('theme');
        $field->setAttributes(XMLDB_TYPE_CHAR, 255, XMLDB_UNSIGNED, null);
        add_field($table, $field);
    }
    if ($oldversion < 2010011300) {
        // Clean up the mess left behind by failing to delete blogposts in a transaction
        try {
            include_once get_config('docroot') . 'artefact/lib.php';
            if (function_exists('rebuild_artefact_parent_cache_dirty')) {
                rebuild_artefact_parent_cache_dirty();
            }
        } catch (Exception $e) {
            log_debug('Upgrade 2010011300: rebuild_artefact_parent_cache_dirty failed.');
        }
        execute_sql("\n            INSERT INTO {artefact_blog_blogpost} (blogpost)\n            SELECT id FROM {artefact} WHERE artefacttype = 'blogpost' AND id NOT IN (\n                SELECT blogpost FROM {artefact_blog_blogpost}\n            )");
    }
    if ($oldversion < 2010012701) {
        set_config('userscanchooseviewthemes', 1);
    }
    if ($oldversion < 2010021500) {
        if ($data = check_upgrades('blocktype.recentforumposts')) {
            upgrade_plugin($data);
        }
    }
    if ($oldversion < 2010031000) {
        // For existing sites, preserve current user search behaviour:
        // Users are only searchable by their display names.
        set_config('userscanhiderealnames', 1);
        execute_sql("\n            INSERT INTO {usr_account_preference} (usr, field, value)\n            SELECT u.id, 'hiderealname', 1\n            FROM {usr} u LEFT JOIN {usr_account_preference} p ON (u.id = p.usr AND p.field = 'hiderealname')\n            WHERE NOT u.preferredname IS NULL AND u.preferredname != '' AND p.field IS NULL\n        ");
    }
    if ($oldversion < 2010040700) {
        // Set antispam defaults
        set_config('formsecret', get_random_key());
        if (!function_exists('checkdnsrr')) {
            require_once get_config('docroot') . 'lib/antispam.php';
        }
        if (checkdnsrr('test.uribl.com.black.uribl.com', 'A')) {
            set_config('antispam', 'advanced');
        } else {
            set_config('antispam', 'simple');
        }
        set_config('spamhaus', 0);
        set_config('surbl', 0);
    }
    if ($oldversion < 2010040800) {
        $table = new XMLDBTable('view');
        $field = new XMLDBField('submittedtime');
        $field->setAttributes(XMLDB_TYPE_DATETIME, null, null);
        add_field($table, $field);
    }
    if ($oldversion < 2010041200) {
        delete_records('config', 'field', 'captchaoncontactform');
        delete_records('config', 'field', 'captchaonregisterform');
    }
    if ($oldversion < 2010041201) {
        $sql = "\n            SELECT u.id\n            FROM {usr} u\n            LEFT JOIN {artefact} a\n                ON (a.owner = u.id AND a.artefacttype = 'blog')\n            WHERE u.id > 0\n            GROUP BY u.id\n            HAVING COUNT(a.id) != 1";
        $manyblogusers = get_records_sql_array($sql, array());
        if ($manyblogusers) {
            foreach ($manyblogusers as $u) {
                $where = (object) array('usr' => $u->id, 'field' => 'multipleblogs');
                $data = (object) array('usr' => $u->id, 'field' => 'multipleblogs', 'value' => 1);
                ensure_record_exists('usr_account_preference', $where, $data);
            }
        }
    }
开发者ID:patkira,项目名称:mahara,代码行数:67,代码来源:upgrade.php


示例7: import_next_user

function import_next_user($filename, $username, $authinstance)
{
    global $ADDEDUSERS, $FAILEDUSERS;
    log_debug('adding user ' . $username . ' from ' . $filename);
    $authobj = get_record('auth_instance', 'id', $authinstance);
    $institution = new Institution($authobj->institution);
    $date = time();
    $nicedate = date('Y/m/d h:i:s', $date);
    $niceuser = preg_replace('/[^a-zA-Z0-9_-]/', '-', $username);
    $uploaddir = get_config('dataroot') . 'import/' . $niceuser . '-' . $date . '/';
    check_dir_exists($uploaddir);
    // Unzip the file
    $archive = new ZipArchive();
    if ($archive->open($filename) && $archive->extractTo($uploaddir)) {
        // successfully extracted
        $archive->close();
    } else {
        $FAILEDUSERS[$username] = get_string('unzipfailed', 'admin', hsc($filename));
        return;
    }
    $leap2afilename = $uploaddir . 'leap2a.xml';
    if (!is_file($leap2afilename)) {
        $FAILEDUSERS[$username] = get_string('noleap2axmlfiledetected', 'admin');
        log_debug($FAILEDUSERS[$username]);
        return;
    }
    // If the username is already taken, append something to the end
    while (get_record('usr', 'username', $username)) {
        $username .= "_";
    }
    $user = (object) array('authinstance' => $authinstance, 'username' => $username, 'firstname' => 'Imported', 'lastname' => 'User', 'password' => get_random_key(6), 'passwordchange' => 1);
    db_begin();
    try {
        $user->id = create_user($user, array(), $institution, $authobj);
    } catch (EmailException $e) {
        // Suppress any emails (e.g. new institution membership) sent out
        // during user creation, becuase the user doesn't have an email
        // address until we've imported them from the Leap2A file.
        log_debug("Failed sending email during user import");
    }
    $niceuser = preg_replace('/[^a-zA-Z0-9_-]/', '-', $user->username);
    $record = (object) array('token' => '', 'usr' => $user->id, 'queue' => (int) (!PluginImport::import_immediately_allowed()), 'ready' => 0, 'expirytime' => db_format_timestamp(time() + 60 * 60 * 24), 'format' => 'leap', 'data' => array('importfile' => $filename, 'importfilename' => $filename, 'importid' => $niceuser . time(), 'mimetype' => file_mime_type($filename)), 'loglevel' => PluginImportLeap::LOG_LEVEL_VERBOSE, 'logtargets' => LOG_TARGET_FILE, 'profile' => true);
    $tr = new LocalImporterTransport($record);
    $tr->extract_file();
    $importer = PluginImport::create_importer(null, $tr, $record);
    unset($record, $tr);
    try {
        $importer->process();
        log_info("Imported user account {$user->id} from Leap2A file, see" . $importer->get('logfile') . 'for a full log');
    } catch (ImportException $e) {
        log_info("Leap2A import failed: " . $e->getMessage());
        $FAILEDUSERS[$username] = get_string("leap2aimportfailed");
        db_rollback();
    }
    db_commit();
    if (empty($FAILEDUSERS[$username])) {
        // Reload the user details, as various fields are changed by the
        // importer when importing (e.g. firstname/lastname)
        $newuser = get_record('usr', 'id', $user->id);
        $newuser->clearpasswd = $user->password;
        $ADDEDUSERS[] = $newuser;
    }
    return;
}
开发者ID:rboyatt,项目名称:mahara,代码行数:64,代码来源:bulkimport.php


示例8: login_form_js

    /**
     * Load all of the Javascript needed to retrieve Personas from
     * the browser.
     */
    public static function login_form_js()
    {
        global $HEADDATA, $SESSION;
        $HEADDATA[] = '<script src="https://login.persona.org/include.js" type="application/javascript"></script>';
        $wwwroot = get_config('wwwroot');
        $returnurl = hsc(get_relative_script_path());
        // We can't use $USER->get('sesskey') because there is no $USER object yet.
        $sesskey = get_random_key();
        $SESSION->set('browseridsesskey', $sesskey);
        return <<<EOF
<form id="browserid-form" action="{$wwwroot}auth/browserid/login.php" method="post">
<input id="browserid-assertion" type="hidden" name="assertion" value="">
<input id="browserid-returnurl" type="hidden" name="returnurl" value="{$returnurl}">
<input id="browserid-sesskey" type="hidden" name="sesskey" value="{$sesskey}">
<input style="display: none" type="submit">
</form>

<script type="application/javascript">
function browserid_login() {
    navigator.id.get(function(assertion) {
        if (assertion) {
            document.getElementById('browserid-assertion').setAttribute('value', assertion);
            document.getElementById('browserid-form').submit();
        }
   });
}
</script>
EOF;
    }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:33,代码来源:lib.php


示例9: profileform_submit

function profileform_submit(Pieform $form, $values)
{
    global $SESSION;
    global $USER;
    global $element_list;
    global $profilefields;
    require_once 'embeddedimage.php';
    db_begin();
    $now = db_format_timestamp(time());
    $email_errors = array();
    $lockedfields = locked_profile_fields();
    foreach ($element_list as $element => $type) {
        if (isset($lockedfields[$element]) && !$USER->get('admin')) {
            continue;
        }
        if ($element == 'email') {
            if (!isset($values['email']['unsent'])) {
                $values['email']['unsent'] = array();
            }
            // find new addresses
            foreach ($values['email']['unsent'] as $email) {
                if (in_array($email, $profilefields['email']['validated']) || in_array($email, $profilefields['email']['unvalidated'])) {
                    continue;
                }
                $key = get_random_key();
                $key_url = get_config('wwwroot') . 'artefact/internal/validate.php?email=' . rawurlencode($email) . '&key=' . $key;
                $key_url_decline = $key_url . '&decline=1';
                try {
                    $sitename = get_config('sitename');
                    email_user((object) array('id' => $USER->get('id'), 'username' => $USER->get('username'), 'firstname' => $USER->get('firstname'), 'lastname' => $USER->get('lastname'), 'preferredname' => $USER->get('preferredname'), 'admin' => $USER->get('admin'), 'staff' => $USER->get('staff'), 'email' => $email), null, get_string('emailvalidation_subject', 'artefact.internal'), get_string('emailvalidation_body1', 'artefact.internal', $USER->get('firstname'), $email, $sitename, $key_url, $sitename, $key_url_decline));
                } catch (EmailException $e) {
                    $email_errors[] = $email;
                }
                insert_record('artefact_internal_profile_email', (object) array('owner' => $USER->get('id'), 'email' => $email, 'verified' => 0, 'key' => $key, 'expiry' => db_format_timestamp(time() + 86400)));
            }
            // remove old addresses
            foreach ($profilefields['email']['validated'] as $email) {
                if (in_array($email, $values['email']['validated'])) {
                    continue;
                }
                if (!empty($values['email']['unvalidated']) && in_array($email, $values['email']['unvalidated'])) {
                    continue;
                }
                $artefact_id = get_field('artefact_internal_profile_email', 'artefact', 'email', $email, 'owner', $USER->get('id'));
                delete_records('artefact_internal_profile_email', 'email', $email, 'owner', $USER->get('id'));
                if ($artefact_id) {
                    $artefact = new ArtefactTypeEmail($artefact_id);
                    $artefact->delete();
                    // this is unset here to force the destructor to run now,
                    // rather than script exit time where it doesn't like
                    // throwing exceptions properly
                    unset($artefact);
                }
            }
            foreach ($profilefields['email']['unvalidated'] as $email) {
                if (in_array($email, $values['email']['validated']) || isset($values['email']['unvalidated']) && in_array($email, $values['email']['unvalidated'])) {
                    continue;
                }
                delete_records('artefact_internal_profile_email', 'email', $email, 'owner', $USER->get('id'));
            }
            if ($profilefields['email']['default'] != $values['email']['default']) {
                update_record('artefact_internal_profile_email', (object) array('principal' => 0), (object) array('owner' => $USER->get('id'), 'email' => $profilefields['email']['default']));
                update_record('artefact_internal_profile_email', (object) array('principal' => 1), (object) array('owner' => $USER->get('id'), 'email' => $values['email']['default']));
                update_record('usr', (object) array('email' => $values['email']['default']), (object) array('id' => $USER->get('id')));
                $USER->email = $values['email']['default'];
                $USER->commit();
            }
        } else {
            if ($element == 'maildisabled') {
                continue;
            } else {
                if ($element == 'socialprofile') {
                    continue;
                } else {
                    if (!isset($profilefields[$element]) || $values[$element] != $profilefields[$element]) {
                        if ($element == 'introduction') {
                            $newintroduction = EmbeddedImage::prepare_embedded_images($values[$element], 'profileintrotext', $USER->get('id'));
                            $values[$element] = $newintroduction;
                        }
                        $classname = generate_artefact_class_name($element);
                        $profile = new $classname(0, array('owner' => $USER->get('id')));
                        $profile->set('title', $values[$element]);
                        $profile->commit();
                    }
                }
            }
        }
    }
    try {
        db_commit();
    } catch (Exception $e) {
        profileform_reply($form, PIEFORM_ERR, get_string('profilefailedsaved', 'artefact.internal'));
    }
    handle_event('updateuser', $USER->get('id'));
    if (count($email_errors)) {
        profileform_reply($form, PIEFORM_ERR, array('message' => get_string('emailingfailed', 'artefact.internal', join(', ', $email_errors))));
    }
    profileform_reply($form, PIEFORM_OK, get_string('profilesaved', 'artefact.internal'));
}
开发者ID:patkira,项目名称:mahara,代码行数:99,代码来源:index.php


示例10: authenticate

 /**
  * When a user creates a security context by whatever method, we do some 
  * standard stuff
  *
  * @param  object $user          Record from the usr table
  * @param  integer $authinstance The ID of the authinstance that the user 
  *                               signed in with
  * @return void
  */
 protected function authenticate($user, $authinstance)
 {
     $this->authenticated = true;
     // If the user has reauthenticated and they were an MNET user, we
     // don't set these variables, because we wish to remember that they
     // originally SSO-ed in from their other authinstance. See the
     // session timeout code in auth_setup() for more info.
     if ($this->SESSION->get('mnetuser') != $user->id) {
         $this->SESSION->set('mnetuser', null);
         $this->SESSION->set('authinstance', $authinstance);
     }
     $this->populate($user);
     session_regenerate_id(true);
     $this->lastlastlogin = $this->lastlogin;
     $this->lastlogin = time();
     $this->lastaccess = time();
     $this->sessionid = session_id();
     $this->logout_time = time() + get_config('session_timeout');
     $this->sesskey = get_random_key();
     // We need a user->id before we load_c*_preferences
     if (empty($user->id)) {
         $this->commit();
     }
     $this->activityprefs = load_activity_preferences($user->id);
     $this->accountprefs = load_account_preferences($user->id);
     $this->reset_institutions();
     $this->reset_grouproles();
     $this->commit();
     // finally, after all is done, call the (maybe non existant) hook on their auth plugin
     $authobj = AuthFactory::create($authinstance);
     $authobj->login();
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:41,代码来源:user.php


示例11: file_get_contents

oAAAAAAAAAD4DR1+AAGgmQaxAAAAAElFTkSuQmCC'), 'text/html' => 'te<b>xt/h</b>tml', 'text/plain' => 'text/plain', 'video/x-flv' => file_get_contents(get_config('docroot') . 'junk.flv'), 'application/octet-stream' => '??');
$profileicons = get_records_sql_array("\n    SELECT f.*, a.artefacttype\n    FROM {artefact_file_files} f JOIN {artefact} a ON f.artefact = a.id\n    WHERE a.artefacttype = 'profileicon'", null);
db_begin();
foreach ($profileicons as $r) {
    $filetype = isset($samples[$r->filetype]) ? $r->filetype : 'application/octet-stream';
    $dir = get_config('dataroot') . 'artefact/file/profileicons/originals/' . $r->artefact % 256;
    check_dir_exists($dir);
    $file = $dir . '/' . $r->artefact;
    if (!file_exists($file)) {
        file_put_contents($dir . '/' . $r->artefact, $samples[$filetype]);
        execute_sql("UPDATE {artefact_file_files} SET size = ?, fileid = ?, filetype = ? WHERE artefact = ?", array(filesize($dir . '/' . $r->artefact), $r->artefact, $filetype, $r->artefact));
    }
}
safe_require('artefact', 'file');
$files = array();
$ids = array();
foreach ($samples as $k => $v) {
    $n = 'a.' . get_random_key();
    $fn = "/tmp/{$n}";
    file_put_contents($fn, $v);
    $d = (object) array('title' => $n, 'owner' => $USER->get('id'), 'filetype' => $k);
    $id = ArtefactTypeFile::save_file($fn, $d, $USER, true);
    $ids[$id] = $id;
    $files[$k] = artefact_instance_from_id($id);
}
$records = get_records_sql_array("\n    SELECT f.*, a.artefacttype\n    FROM {artefact_file_files} f JOIN {artefact} a ON f.artefact = a.id\n    WHERE a.artefacttype != 'profileicon' AND NOT a.id IN (" . join(',', $ids) . ')', null);
foreach ($samples as $k => $v) {
    execute_sql("\n        UPDATE {artefact_file_files} SET size = ?, fileid = ? WHERE filetype = ?", array($files[$k]->get('size'), $files[$k]->get('fileid'), $k));
}
db_commit();
set_config('samplefiles', 1);
开发者ID:felixod,项目名称:mahara-scripts,代码行数:31,代码来源:samplefiles.php


示例12: xmldb_core_upgrade


//.........这里部分代码省略.........
    }
    if ($oldversion < 2009021700) {
        try {
            include_once 'xmlize.php';
            $newlist = xmlize(file_get_contents(get_config('libroot') . 'htmlpurifiercustom/filters.xml'));
            $filters = $newlist['filters']['#']['filter'];
            foreach ($filters as &$f) {
                $f = (object) array('site' => $f['#']['site'][0]['#'], 'file' => $f['#']['filename'][0]['#']);
            }
            $filters[] = (object) array('site' => 'http://www.youtube.com', 'file' => 'YouTube');
            set_config('filters', serialize($filters));
        } catch (Exception $e) {
            log_debug('Upgrade 2009021700: failed to load html filters');
        }
    }
    if ($oldversion < 2009021701) {
        // Make sure that all views that can be copied have loggedin access
        // This upgrade just fixes potentially corrupt data caused by running a
        // beta version then upgrading it
        if ($views = get_column('view', 'id', 'copynewuser', '1')) {
            $views[] = 1;
            foreach ($views as $viewid) {
                if (!record_exists('view_access', 'view', $viewid, 'accesstype', 'loggedin')) {
                    // We're not checking that access dates are null (aka
                    // it can always be accessed), but the chance of people
                    // needing this upgrade are slim anyway
                    insert_record('view_access', (object) array('view' => $viewid, 'accesstype' => 'loggedin', 'startdate' => null, 'stopdate' => null));
                }
            }
        }
    }
    if ($oldversion < 2009021900) {
        // Generate a unique installation key
        set_config('installation_key', get_random_key());
    }
    if ($oldversion < 2009021901) {
        // Insert a cron job to send registration data to mahara.org
        $cron = new StdClass();
        $cron->callfunction = 'cron_send_registration_data';
        $cron->minute = rand(0, 59);
        $cron->hour = rand(0, 23);
        $cron->day = '*';
        $cron->month = '*';
        $cron->dayofweek = rand(0, 6);
        insert_record('cron', $cron);
    }
    if ($oldversion < 2009022700) {
        // Get rid of all blocks with position 0 caused by 'about me' block on profile views
        if (count_records('block_instance', 'order', 0) && !count_records_select('block_instance', '"order" < 0')) {
            if (is_mysql()) {
                $ids = get_column_sql('
                    SELECT i.id FROM {block_instance} i
                    INNER JOIN (SELECT view, "column" FROM {block_instance} WHERE "order" = 0) z
                        ON (z.view = i.view AND z.column = i.column)');
                execute_sql('UPDATE {block_instance} SET "order" =  -1 * "order" WHERE id IN (' . join(',', $ids) . ')');
            } else {
                execute_sql('UPDATE {block_instance} SET "order" =  -1 * "order" WHERE id IN (
                    SELECT i.id FROM {block_instance} i
                    INNER JOIN (SELECT view, "column" FROM {block_instance} WHERE "order" = 0) z
                        ON (z.view = i.view AND z.column = i.column))');
            }
            execute_sql('UPDATE {block_instance} SET "order" = 1 WHERE "order" = 0');
            execute_sql('UPDATE {block_instance} SET "order" = -1 * ("order" - 1) WHERE "order" < 0');
        }
    }
    if ($oldversion < 2009031000) {
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:67,代码来源:upgrade.php


示例13: register_submit

function register_submit(Pieform $form, $values)
{
    global $SESSION;
    // store password encrypted
    // don't die_info, since reloading the page shows the login form.
    // instead, redirect to some other page that says this
    safe_require('auth', 'internal');
    $values['salt'] = substr(md5(rand(1000000, 9999999)), 2, 8);
    $values['password'] = AuthInternal::encrypt_password($values['password1'], $values['salt']);
    $values['key'] = get_random_key();
    // @todo the expiry date should be configurable
    $values['expiry'] = db_format_timestamp(time() + 86400);
    $values['lang'] = $SESSION->get('lang');
    try {
        insert_record('usr_registration', $values);
        $f = fopen('/tmp/donal.txt', 'w');
        fwrite($f, get_string('registeredemailmessagetext', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('wwwroot'), $values['key'], get_config('sitename')));
        $user = (object) $values;
        $user->admin = 0;
        $user->staff = 0;
        email_user($user, null, get_string('registeredemailsubject', 'auth.internal', get_config('sitename')), get_string('registeredemailmessagetext', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('wwwroot'), $values['key'], get_config('sitename')), get_string('registeredemailmessagehtml', 'auth.internal', $values['firstname'], get_config('sitename'), get_config('wwwroot'), $values['key'], get_config('wwwroot'), $values['key'], get_config('sitename')));
    } catch (EmailException $e) {
        log_warn($e);
        die_info(get_string('registrationunsuccessful', 'auth.internal'));
    } catch (SQLException $e) {
        log_warn($e);
        die_info(get_string('registrationunsuccessful', 'auth.internal'));
    }
    // Add a marker in the session to say that the user has registered
    $_SESSION['registered'] = true;
    redirect('/register.php');
}
开发者ID:Br3nda,项目名称:mahara,代码行数:32,代码来源:register.php


示例14: _

     echo "<input type=\"hidden\" name=\"pa_pass\" value=\"" . $pa_pass . "\">";
     echo "<input type=\"hidden\" name=\"dns_hostmaster\" value=\"" . $dns_hostmaster . "\">";
     echo "<input type=\"hidden\" name=\"dns_ns1\" value=\"" . $dns_ns1 . "\">";
     echo "<input type=\"hidden\" name=\"dns_ns2\" value=\"" . $dns_ns2 . "\">";
     echo "<input type=\"hidden\" name=\"step\" value=\"" . $step . "\">";
     echo "<input type=\"hidden\" name=\"language\" value=\"" . $language . "\">";
     echo "<input type=\"submit\" name=\"submit\" value=\"" . _('Go to step') . " " . $step . "\">";
     echo "</form>";
     break;
 case 6:
     $step++;
     require_once "../inc/database.inc.php";
     $db_type = $_POST['db_type'];
     $pa_pass = $_POST['pa_pass'];
     $db_port = $_POST['db_port'];
     $config = "<?php\n\n" . ($db_type == 'sqlite' ? "\$db_file\t\t= '" . $_POST['db_name'] . "';\n" : "\$db_host\t\t= '" . $_POST['db_host'] . "';\n" . "\$db_user\t\t= '" . $_POST['pa_db_user'] . "';\n" . "\$db_pass\t\t= '" . $_POST['pa_db_pass'] . "';\n" . "\$db_name\t\t= '" . $_POST['db_name'] . "';\n" . ($db_type == 'mysql' && $db_port != 3306 || $db_type == 'pgsql' && $db_port != 5432 ? "\$db_port\t\t= '" . $db_port . "';\n" : '')) . "\$db_type\t\t= '" . $_POST['db_type'] . "';\n" . "\n" . "\$session_key\t\t= '" . get_random_key() . "';\n" . "\n" . "\$iface_lang\t\t= '" . $_POST['language'] . "';\n" . "\n" . "\$dns_hostmaster\t\t= '" . $_POST['dns_hostmaster'] . "';\n" . "\$dns_ns1\t\t= '" . $_POST['dns_ns1'] . "';\n" . "\$dns_ns2\t\t= '" . $_POST['dns_ns2'] . "';\n";
     if (is_writeable($local_config_file)) {
         $h_config = fopen($local_config_file, "w");
         fwrite($h_config, $config);
         fclose($h_config);
         echo "<p>" . _('The installer was able to write to the file "') . $local_config_file . _('". A basic configuration, based on the details you have given, has been created.') . "</p>\n";
     } else {
         echo "<p>" . _('The installer is unable to write to the file "') . $local_config_file . _('" (which is in itself good). The configuration is printed here. You should now create the file "') . $local_config_file . _('" in the Poweradmin root directory yourself. It should contain the following few lines:') . "</p>\n";
         echo "<pre>";
         echo htmlentities($config);
         echo "</pre>";
     }
     echo "<form method=\"post\">";
     echo "<input type=\"hidden\" name=\"pa_pass\" value=\"" . $pa_pass . "\">";
     echo "<input type=\"hidden\" name=\"step\" value=\"" . $step . "\">";
     echo "<input type=\"hidden\" name=\"language\" value=\"" . $language . "\">";
开发者ID:eraserewind,项目名称:poweradmin,代码行数:31,代码来源:index.php


示例15: import_next_user

function import_next_user()
{
    global $SESSION, $ADDEDUSERS, $FAILEDUSERS, $LEAP2AFILES, $AUTHINSTANCE;
    require_once get_config('docroot') . 'import/lib.php';
    safe_require('import', 'leap');
    // Pop the last element off of the LEAP2AFILES array
    $filename = end($LEAP2AFILES);
    $username = key($LEAP2AFILES);
    unset($LEAP2AFILES[$username]);
    log_debug('adding user ' . $username . ' from ' . $filename);
    $authobj = get_record('auth_instance', 'id', $AUTHINSTANCE);
    $institution = new Institution($authobj->institution);
    $date = time();
    $nicedate = date('Y/m/d h:i:s', $date);
    $niceuser = preg_replace('/[^a-zA-Z0-9_-]/', '-', $username);
    $uploaddir = get_config('dataroot') . 'import/' . $niceuser . '-' . $date . '/';
    check_dir_exists($uploaddir);
    // Unzip the file
    $command = sprintf('%s %s %s %s', escapeshellcmd(get_config('pathtounzip')), escapeshellarg($filename), get_config('unzipdirarg'), escapeshellarg($uploaddir));
    $output = array();
    exec($command, $output, $returnvar);
    if ($returnvar != 0) {
        $FAILEDUSERS[$username] = get_string('unzipfailed', 'admin', hsc($filename));
        log_debug("unzip command failed with return value {$returnvar}");
        continue;
    }
    $leap2afilename = $uploaddir . 'leap2a.xml';
    if (!is_file($leap2afilename)) {
        $FAILEDUSERS[$username] = get_string('noleap2axmlfiledetected', 'admin');
        log_debug($FAILEDUSERS[$username]);
        continue;
    }
    // If the username is already taken, append something to the end
    while (get_record('usr', 'username', $username)) {
        $username .= "_";
    }
    $user = (object) array('authinstance' => $AUTHINSTANCE, 'username' => $username, 'firstname' => 'Imported', 'lastname' => 'User', 'password' => get_random_key(6), 'passwordchange' => 1);
    db_begin();
    try {
        $user->id = create_user($user, array(), $institution, $authobj);
    } catch (EmailException $e) {
        // Suppress any emails (e.g. new institution membership) sent out
        // during user creation, becuase the user doesn't have an email
        // address until we've imported them from the Leap2A file.
        log_debug("Failed sending email during user import");
    }
    $importerfilename = substr($leap2afilename, strlen(get_config('dataroot')));
    $logfile = dirname($leap2afilename) . '/import.log';
    $importer = PluginImport::create_importer(null, (object) array('token' => '', 'usr' => $user->id, 'queue' => (int) (!PluginImport::import_immediately_allowed()), 'ready' => 0, 'expirytime' => db_format_timestamp(time() + 60 * 60 * 24), 'format' => 'leap', 'data' => array('filename' => $importerfilename), 'loglevel' => PluginImportLeap::LOG_LEVEL_VERBOSE, 'logtargets' => LOG_TARGET_FILE, 'logfile' => $logfile, 'profile' => true));
    try {
        $importer->process();
        log_info("Imported user account {$user->id} from Leap2A file, see {$logfile} for a full log");
    } catch (ImportException $e) {
        log_info("Leap2A import failed: " . $e->getMessage());
        $FAILEDUS 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_random_string函数代码示例发布时间:2022-05-15
下一篇:
PHP get_random_header_image函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap