-/*function get_guid($size=16) {
- $exists = true; // assume by default that we don't have a unique guid
- do {
- $s = random_string($size);
- $r = q("select id from guid where guid = '%s' limit 1", dbesc($s));
- if(! count($r))
- $exists = false;
- } while($exists);
- q("insert into guid ( guid ) values ( '%s' ) ", dbesc($s));
- return $s;
-}*/
-
-
-// wrapper for adding a login box. If $register == true provide a registration
-// link. This will most always depend on the value of $a->config['register_policy'].
-// returns the complete html for inserting into the page
-
-if(! function_exists('login')) {
- function login($register = false, $hiddens=false) {
- $a = get_app();
- $o = "";
- $reg = false;
- if ($register) {
- $reg = array(
- 'title' => t('Create a New Account'),
- 'desc' => t('Register')
- );
- }
-
- $noid = get_config('system','no_openid');
-
- $dest_url = $a->get_baseurl(true) . '/' . $a->query_string;
-
- if(local_user()) {
- $tpl = get_markup_template("logout.tpl");
- }
- else {
- $a->page['htmlhead'] .= replace_macros(get_markup_template("login_head.tpl"),array(
- '$baseurl' => $a->get_baseurl(true)
- ));
-
- $tpl = get_markup_template("login.tpl");
- $_SESSION['return_url'] = $a->query_string;
- $a->module = 'login';
- }
-
- $o .= replace_macros($tpl, array(
-
- '$dest_url' => $dest_url,
- '$logout' => t('Logout'),
- '$login' => t('Login'),
-
- '$lname' => array('username', t('Nickname or Email address: ') , '', ''),
- '$lpassword' => array('password', t('Password: '), '', ''),
- '$lremember' => array('remember', t('Remember me'), 0, ''),
-
- '$openid' => !$noid,
- '$lopenid' => array('openid_url', t('Or login using OpenID: '),'',''),
-
- '$hiddens' => $hiddens,
-
- '$register' => $reg,