当前位置: 首页>>代码示例>>PHP>>正文


PHP pop_lang函数代码示例

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


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

示例1: user_allow

function user_allow($hash)
{
    $a = get_app();
    $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($hash));
    if (!count($register)) {
        return false;
    }
    $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($register[0]['uid']));
    if (!count($user)) {
        killme();
    }
    $r = q("DELETE FROM `register` WHERE `hash` = '%s'", dbesc($register[0]['hash']));
    $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d", intval($register[0]['uid']));
    $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1", intval($user[0]['uid']));
    if (count($r) && $r[0]['net-publish']) {
        $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
        if ($url && strlen(get_config('system', 'directory'))) {
            proc_run('php', "include/directory.php", "{$url}");
        }
    }
    push_lang($register[0]['language']);
    send_register_open_eml($user[0]['email'], $a->config['sitename'], $a->get_baseurl(), $user[0]['username'], $register[0]['password']);
    pop_lang();
    if ($res) {
        info(t('Account approved.') . EOL);
        return true;
    }
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:28,代码来源:regmod.php

示例2: user_allow

function user_allow($hash)
{
    $a = get_app();
    $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($hash));
    if (!count($register)) {
        return false;
    }
    $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($register[0]['uid']));
    if (!count($user)) {
        killme();
    }
    $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($register[0]['hash']));
    $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d LIMIT 1", intval($register[0]['uid']));
    $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1", intval($user[0]['uid']));
    if (count($r) && $r[0]['net-publish']) {
        $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
        if ($url && strlen(get_config('system', 'directory_submit_url'))) {
            proc_run('php', "include/directory.php", "{$url}");
        }
    }
    push_lang($register[0]['language']);
    $email_tpl = get_intltext_template("register_open_eml.tpl");
    $email_tpl = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => $user[0]['username'], '$email' => $user[0]['email'], '$password' => $register[0]['password'], '$uid' => $user[0]['uid']));
    $res = mail($user[0]['email'], sprintf(t('Registration details for %s'), $a->config['sitename']), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
    pop_lang();
    if ($res) {
        info(t('Account approved.') . EOL);
        return true;
    }
}
开发者ID:robhell,项目名称:friendica,代码行数:30,代码来源:regmod.php

示例3: notification

function notification($params)
{
    #logger('notification()', LOGGER_DEBUG);
    $a = get_app();
    // from here on everything is in the recipients language
    push_lang($params['language']);
    $banner = t('Friendica Notification');
    $product = FRIENDICA_PLATFORM;
    $siteurl = $a->get_baseurl(true);
    $thanks = t('Thank You,');
    $sitename = $a->config['sitename'];
    $site_admin = sprintf(t('%s Administrator'), $sitename);
    $nickname = "";
    $sender_name = $sitename;
    $hostname = $a->get_hostname();
    if (strpos($hostname, ':')) {
        $hostname = substr($hostname, 0, strpos($hostname, ':'));
    }
    $sender_email = $a->config['sender_email'];
    if (empty($sender_email)) {
        $sender_email = t('noreply') . '@' . $hostname;
    }
    $user = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($params['uid']));
    if ($user) {
        $nickname = $user[0]["nickname"];
    }
    // with $params['show_in_notification_page'] == false, the notification isn't inserted into
    // the database, and an email is sent if applicable.
    // default, if not specified: true
    $show_in_notification_page = x($params, 'show_in_notification_page') ? $params['show_in_notification_page'] : True;
    $additional_mail_header = "";
    $additional_mail_header .= "Precedence: list\n";
    $additional_mail_header .= "X-Friendica-Host: " . $hostname . "\n";
    $additional_mail_header .= "X-Friendica-Account: <" . $nickname . "@" . $hostname . ">\n";
    $additional_mail_header .= "X-Friendica-Platform: " . FRIENDICA_PLATFORM . "\n";
    $additional_mail_header .= "X-Friendica-Version: " . FRIENDICA_VERSION . "\n";
    $additional_mail_header .= "List-ID: <notification." . $hostname . ">\n";
    $additional_mail_header .= "List-Archive: <" . $a->get_baseurl() . "/notifications/system>\n";
    if (array_key_exists('item', $params)) {
        $title = $params['item']['title'];
        $body = $params['item']['body'];
    } else {
        $title = $body = '';
    }
    // e.g. "your post", "David's photo", etc.
    $possess_desc = t('%s <!item_type!>');
    if ($params['type'] == NOTIFY_MAIL) {
        $subject = sprintf(t('[Friendica:Notify] New mail received at %s'), $sitename);
        $preamble = sprintf(t('%1$s sent you a new private message at %2$s.'), $params['source_name'], $sitename);
        $epreamble = sprintf(t('%1$s sent you %2$s.'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]');
        $sitelink = t('Please visit %s to view and/or reply to your private messages.');
        $tsitelink = sprintf($sitelink, $siteurl . '/message/' . $params['item']['id']);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '/message/' . $params['item']['id'] . '">' . $sitename . '</a>');
        $itemlink = $siteurl . '/message/' . $params['item']['id'];
    }
    if ($params['type'] == NOTIFY_COMMENT) {
        //		logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
        $parent_id = $params['parent'];
        $p = q("SELECT `ignored` FROM `thread` WHERE `iid` = %d AND `uid` = %d LIMIT 1", intval($parent_id), intval($params['uid']));
        if ($p and count($p) and $p[0]["ignored"]) {
            logger("Thread " . $parent_id . " will be ignored", LOGGER_DEBUG);
            return;
        }
        // Check to see if there was already a tag notify or comment notify for this post.
        // If so don't create a second notification
        $p = null;
        $p = q("select id from notify where (type = %d or type = %d or type = %d) and link = '%s' and uid = %d limit 1", intval(NOTIFY_TAGSELF), intval(NOTIFY_COMMENT), intval(NOTIFY_SHARE), dbesc($params['link']), intval($params['uid']));
        if ($p and count($p)) {
            pop_lang();
            return;
        }
        // if it's a post figure out who's post it is.
        $p = null;
        if ($params['otype'] === 'item' && $parent_id) {
            $p = q("select * from item where id = %d and uid = %d limit 1", intval($parent_id), intval($params['uid']));
        }
        $item_post_type = item_post_type($p[0]);
        //$possess_desc = str_replace('<!item_type!>',$possess_desc);
        // "a post"
        $dest_str = sprintf(t('%1$s commented on [url=%2$s]a %3$s[/url]'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', $itemlink, $item_post_type);
        // "George Bull's post"
        if ($p) {
            $dest_str = sprintf(t('%1$s commented on [url=%2$s]%3$s\'s %4$s[/url]'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', $itemlink, $p[0]['author-name'], $item_post_type);
        }
        // "your post"
        if ($p[0]['owner-name'] == $p[0]['author-name'] && $p[0]['wall']) {
            $dest_str = sprintf(t('%1$s commented on [url=%2$s]your %3$s[/url]'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', $itemlink, $item_post_type);
        }
        // Some mail softwares relies on subject field for threading.
        // So, we cannot have different subjects for notifications of the same thread.
        // Before this we have the name of the replier on the subject rendering
        // differents subjects for messages on the same thread.
        $subject = sprintf(t('[Friendica:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $params['source_name']);
        $preamble = sprintf(t('%s commented on an item/conversation you have been following.'), $params['source_name']);
        $epreamble = $dest_str;
        $sitelink = t('Please visit %s to view and/or reply to the conversation.');
        $tsitelink = sprintf($sitelink, $siteurl);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
        $itemlink = $params['link'];
    }
//.........这里部分代码省略.........
开发者ID:strk,项目名称:friendica,代码行数:101,代码来源:enotify.php

示例4: submit

 /**
  * @brief
  *
  * @param array $params an assoziative array with:
  *  * \e string \b from_xchan sender xchan hash
  *  * \e string \b to_xchan recipient xchan hash
  *  * \e array \b item an assoziative array
  *  * \e int \b type one of the NOTIFY_* constants from boot.php
  *  * \e string \b link
  *  * \e string \b parent_mid
  *  * \e string \b otype
  *  * \e string \b verb
  *  * \e string \b activity
  */
 public static function submit($params)
 {
     logger('notification: entry', LOGGER_DEBUG);
     // throw a small amount of entropy into the system to breakup duplicates arriving at the same precise instant.
     usleep(mt_rand(0, 10000));
     if ($params['from_xchan']) {
         $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($params['from_xchan']));
     }
     if ($params['to_xchan']) {
         $y = q("select channel.*, account.* from channel left join account on channel_account_id = account_id\n\t\t\t\twhere channel_hash = '%s' and channel_removed = 0 limit 1", dbesc($params['to_xchan']));
     }
     if ($x & $y) {
         $sender = $x[0];
         $recip = $y[0];
     } else {
         logger('notification: no sender or recipient.');
         logger('sender: ' . $params['from_xchan']);
         logger('recip: ' . $params['to_xchan']);
         return;
     }
     // from here on everything is in the recipients language
     push_lang($recip['account_language']);
     // should probably have a channel language
     $banner = t('$Projectname Notification');
     $product = t('$projectname');
     // PLATFORM_NAME;
     $siteurl = z_root();
     $thanks = t('Thank You,');
     $sitename = get_config('system', 'sitename');
     $site_admin = sprintf(t('%s Administrator'), $sitename);
     $sender_name = $product;
     $hostname = \App::get_hostname();
     if (strpos($hostname, ':')) {
         $hostname = substr($hostname, 0, strpos($hostname, ':'));
     }
     // Do not translate 'noreply' as it must be a legal 7-bit email address
     $reply_email = get_config('system', 'reply_address');
     if (!$reply_email) {
         $reply_email = 'noreply' . '@' . $hostname;
     }
     $sender_email = get_config('system', 'from_email');
     if (!$sender_email) {
         $sender_email = 'Administrator' . '@' . \App::get_hostname();
     }
     $sender_name = get_config('system', 'from_email_name');
     if (!$sender_name) {
         $sender_name = \Zotlabs\Lib\System::get_site_name();
     }
     $additional_mail_header = "";
     if (array_key_exists('item', $params)) {
         require_once 'include/conversation.php';
         // if it's a normal item...
         if (array_key_exists('verb', $params['item'])) {
             // localize_item() alters the original item so make a copy first
             $i = $params['item'];
             logger('calling localize');
             localize_item($i);
             $title = $i['title'];
             $body = $i['body'];
             $private = $i['item_private'] || intval($i['item_obscured']);
         } else {
             $title = $params['item']['title'];
             $body = $params['item']['body'];
         }
     } else {
         $title = $body = '';
     }
     // e.g. "your post", "David's photo", etc.
     $possess_desc = t('%s <!item_type!>');
     if ($params['type'] == NOTIFY_MAIL) {
         logger('notification: mail');
         $subject = sprintf(t('[$Projectname:Notify] New mail received at %s'), $sitename);
         $preamble = sprintf(t('%1$s, %2$s sent you a new private message at %3$s.'), $recip['channel_name'], $sender['xchan_name'], $sitename);
         $epreamble = sprintf(t('%1$s sent you %2$s.'), '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', '[zrl=$itemlink]' . t('a private message') . '[/zrl]');
         $sitelink = t('Please visit %s to view and/or reply to your private messages.');
         $tsitelink = sprintf($sitelink, $siteurl . '/mail/' . $params['item']['id']);
         $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '/mail/' . $params['item']['id'] . '">' . $sitename . '</a>');
         $itemlink = $siteurl . '/mail/' . $params['item']['id'];
     }
     if ($params['type'] == NOTIFY_COMMENT) {
         //		logger("notification: params = " . print_r($params, true), LOGGER_DEBUG);
         $itemlink = $params['link'];
         // ignore like/unlike activity on posts - they probably require a separate notification preference
         if (array_key_exists('item', $params) && !visible_activity($params['item'])) {
             logger('notification: not a visible activity. Ignoring.');
             pop_lang();
//.........这里部分代码省略.........
开发者ID:phellmes,项目名称:hubzilla,代码行数:101,代码来源:Enotify.php

示例5: account_allow

/**
 * @brief Allows a user registration.
 *
 * @param string $hash
 * @return array|boolean
 */
function account_allow($hash)
{
    $ret = array('success' => false);
    $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($hash));
    if (!$register) {
        return $ret;
    }
    $account = q("SELECT * FROM account WHERE account_id = %d LIMIT 1", intval($register[0]['uid']));
    if (!$account) {
        return $ret;
    }
    $r = q("DELETE FROM register WHERE hash = '%s'", dbesc($register[0]['hash']));
    $r = q("update account set account_flags = (account_flags & ~%d) where (account_flags & %d)>0 and account_id = %d", intval(ACCOUNT_BLOCKED), intval(ACCOUNT_BLOCKED), intval($register[0]['uid']));
    $r = q("update account set account_flags = (account_flags & ~%d) where (account_flags & %d)>0 and account_id = %d", intval(ACCOUNT_PENDING), intval(ACCOUNT_PENDING), intval($register[0]['uid']));
    push_lang($register[0]['language']);
    $email_tpl = get_intltext_template("register_open_eml.tpl");
    $email_tpl = replace_macros($email_tpl, array('$sitename' => get_config('system', 'sitename'), '$siteurl' => z_root(), '$username' => $account[0]['account_email'], '$email' => $account[0]['account_email'], '$password' => '', '$uid' => $account[0]['account_id']));
    $res = mail($account[0]['account_email'], sprintf(t('Registration details for %s'), get_config('system', 'sitename')), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
    pop_lang();
    if (get_config('system', 'auto_channel_create')) {
        auto_channel_create($register[0]['uid']);
    }
    if ($res) {
        info(t('Account approved.') . EOL);
        return true;
    }
}
开发者ID:bashrc,项目名称:hubzilla,代码行数:33,代码来源:account.php

示例6: register_post


//.........这里部分代码省略.........
      * due to race condition. Remove this one.
      */
     $r = q("SELECT `uid` FROM `user`\n               \tWHERE `nickname` = '%s' ", dbesc($nickname));
     if (count($r) > 1 && $newuid) {
         $err .= t('Nickname is already registered. Please choose another.') . EOL;
         q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1", intval($newuid));
         notice($err);
         return;
     }
     if (x($newuid) !== false) {
         $r = q("INSERT INTO `profile` ( `uid`, `profile-name`, `is-default`, `name`, `photo`, `thumb`, `publish`, `net-publish` )\n\t\t\tVALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, %d ) ", intval($newuid), 'default', 1, dbesc($username), dbesc($a->get_baseurl() . "/photo/profile/{$newuid}.jpg"), dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}.jpg"), intval($publish), intval($netpublish));
         if ($r === false) {
             notice(t('An error occurred creating your default profile. Please try again.') . EOL);
             // Start fresh next time.
             $r = q("DELETE FROM `user` WHERE `uid` = %d", intval($newuid));
             return;
         }
         $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `nurl`,\n\t\t\t`request`, `notify`, `poll`, `confirm`, `poco`, `name-date`, `uri-date`, `avatar-date` )\n\t\t\tVALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", intval($newuid), datetime_convert(), dbesc($username), dbesc($nickname), dbesc($a->get_baseurl() . "/photo/profile/{$newuid}.jpg"), dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}.jpg"), dbesc($a->get_baseurl() . "/photo/micro/{$newuid}.jpg"), dbesc($a->get_baseurl() . "/profile/{$nickname}"), dbesc(normalise_link($a->get_baseurl() . "/profile/{$nickname}")), dbesc($a->get_baseurl() . "/dfrn_request/{$nickname}"), dbesc($a->get_baseurl() . "/dfrn_notify/{$nickname}"), dbesc($a->get_baseurl() . "/dfrn_poll/{$nickname}"), dbesc($a->get_baseurl() . "/dfrn_confirm/{$nickname}"), dbesc($a->get_baseurl() . "/poco/{$nickname}"), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()));
     }
     $use_gravatar = get_config('system', 'no_gravatar') ? false : true;
     // if we have an openid photo use it.
     // otherwise unless it is disabled, use gravatar
     if ($use_gravatar || strlen($photo)) {
         require_once 'include/Photo.php';
         if ($use_gravatar && !strlen($photo)) {
             $photo = gravatar_img($email);
         }
         $photo_failure = false;
         $filename = basename($photo);
         $img_str = fetch_url($photo, true);
         $img = new Photo($img_str);
         if ($img->is_valid()) {
             $img->scaleImageSquare(175);
             $hash = photo_new_resource();
             $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4);
             if ($r === false) {
                 $photo_failure = true;
             }
             $img->scaleImage(80);
             $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 5);
             if ($r === false) {
                 $photo_failure = true;
             }
             $img->scaleImage(48);
             $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 6);
             if ($r === false) {
                 $photo_failure = true;
             }
             if (!$photo_failure) {
                 q("UPDATE `photo` SET `profile` = 1 WHERE `resource-id` = '%s' ", dbesc($hash));
             }
         }
     }
     if ($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) {
         $url = $a->get_baseurl() . "/profile/{$nickname}";
         proc_run('php', "include/directory.php", "{$url}");
     }
     call_hooks('register_account', $newuid);
     if ($a->config['register_policy'] == REGISTER_OPEN) {
         if ($using_invites && $invite_id) {
             q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
             set_pconfig($newuid, 'system', 'invites_remaining', $num_invites);
         }
         $email_tpl = get_intltext_template("register_open_eml.tpl");
         $email_tpl = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => $username, '$email' => $email, '$password' => $new_password, '$uid' => $newuid));
         $res = mail($email, sprintf(t('Registration details for %s'), $a->config['sitename']), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
         if ($res) {
             info(t('Registration successful. Please check your email for further instructions.') . EOL);
             goaway(z_root());
         } else {
             notice(t('Failed to send email message. Here is the message that failed.') . $email_tpl . EOL);
         }
     } elseif ($a->config['register_policy'] == REGISTER_APPROVE) {
         if (!strlen($a->config['admin_email'])) {
             notice(t('Your registration can not be processed.') . EOL);
             goaway(z_root());
         }
         $hash = random_string();
         $r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language` ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ", dbesc($hash), dbesc(datetime_convert()), intval($newuid), dbesc($new_password), dbesc($lang));
         $r = q("SELECT `language` FROM `user` WHERE `email` = '%s' LIMIT 1", dbesc($a->config['admin_email']));
         if (count($r)) {
             push_lang($r[0]['language']);
         } else {
             push_lang('en');
         }
         if ($using_invites && $invite_id) {
             q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
             set_pconfig($newuid, 'system', 'invites_remaining', $num_invites);
         }
         $email_tpl = get_intltext_template("register_verify_eml.tpl");
         $email_tpl = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => $username, '$email' => $email, '$password' => $new_password, '$uid' => $newuid, '$hash' => $hash));
         $res = mail($a->config['admin_email'], sprintf(t('Registration request at %s'), $a->config['sitename']), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
         pop_lang();
         if ($res) {
             info(t('Your registration is pending approval by the site owner.') . EOL);
             goaway(z_root());
         }
     }
     return;
 }
开发者ID:ryivhnn,项目名称:friendica,代码行数:101,代码来源:register.php

示例7: notification


//.........这里部分代码省略.........
    call_hooks('enotify', $h);
    $subject = $h['subject'];
    $preamble = $h['preamble'];
    $epreamble = $h['epreamble'];
    $body = $h['body'];
    $sitelink = $h['sitelink'];
    $tsitelink = $h['tsitelink'];
    $hsitelink = $h['hsitelink'];
    $itemlink = $h['itemlink'];
    require_once 'include/html2bbcode.php';
    do {
        $dups = false;
        $hash = random_string();
        $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1", dbesc($hash));
        if (count($r)) {
            $dups = true;
        }
    } while ($dups == true);
    $datarray = array();
    $datarray['hash'] = $hash;
    $datarray['name'] = $params['source_name'];
    $datarray['url'] = $params['source_link'];
    $datarray['photo'] = $params['source_photo'];
    $datarray['date'] = datetime_convert();
    $datarray['uid'] = $params['uid'];
    $datarray['link'] = $itemlink;
    $datarray['parent'] = $parent_id;
    $datarray['type'] = $params['type'];
    $datarray['verb'] = $params['verb'];
    $datarray['otype'] = $params['otype'];
    call_hooks('enotify_store', $datarray);
    // create notification entry in DB
    $r = q("insert into notify (hash,name,url,photo,date,uid,link,parent,type,verb,otype)\n\t\tvalues('%s','%s','%s','%s','%s',%d,'%s',%d,%d,'%s','%s')", dbesc($datarray['hash']), dbesc($datarray['name']), dbesc($datarray['url']), dbesc($datarray['photo']), dbesc($datarray['date']), intval($datarray['uid']), dbesc($datarray['link']), intval($datarray['parent']), intval($datarray['type']), dbesc($datarray['verb']), dbesc($datarray['otype']));
    $r = q("select id from notify where hash = '%s' and uid = %d limit 1", dbesc($hash), intval($params['uid']));
    if ($r) {
        $notify_id = $r[0]['id'];
    } else {
        pop_lang();
        return;
    }
    $itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
    $msg = replace_macros($epreamble, array('$itemlink' => $itemlink));
    $r = q("update notify set msg = '%s' where id = %d and uid = %d limit 1", dbesc($msg), intval($notify_id), intval($params['uid']));
    // send email notification if notification preferences permit
    require_once 'bbcode.php';
    if (intval($params['notify_flags']) & intval($params['type']) || $params['type'] == NOTIFY_SYSTEM) {
        logger('notification: sending notification email');
        $id_for_parent = "{$params['parent']}@{$hostname}";
        // Is this the first email notification for this parent item and user?
        $r = q("select `id` from `notify-threads` where `master-parent-item` = %d and `receiver-uid` = %d limit 1", intval($params['parent']), intval($params['uid']));
        // If so, create the record of it and use a message-id smtp header.
        if (!$r) {
            logger("norify_id:" . intval($notify_id) . ", parent: " . intval($params['parent']) . "uid: " . intval($params['uid']), LOGGER_DEBUG);
            $r = q("insert into `notify-threads` (`notify-id`, `master-parent-item`, `receiver-uid`, `parent-item`)\n\t\t\t\tvalues(%d,%d,%d,%d)", intval($notify_id), intval($params['parent']), intval($params['uid']), 0);
            $additional_mail_header .= "Message-ID: <{$id_for_parent}>\n";
            $log_msg = "include/enotify: No previous notification found for this parent:\n" . "  parent: {$params['parent']}\n" . "  uid   : {$params['uid']}\n";
            logger($log_msg, LOGGER_DEBUG);
        } else {
            $additional_mail_header = "References: <{$id_for_parent}>\nIn-Reply-To: <{$id_for_parent}>\n";
            logger("include/enotify: There's already a notification for this parent:\n" . print_r($r, true), LOGGER_DEBUG);
        }
        $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n", $body))), ENT_QUOTES, 'UTF-8'));
        $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n\\n", "\\n"), "<br />\n", $body))));
        $datarray = array();
        $datarray['banner'] = $banner;
        $datarray['product'] = $product;
        $datarray['preamble'] = $preamble;
        $datarray['sitename'] = $sitename;
        $datarray['siteurl'] = $siteurl;
        $datarray['type'] = $params['type'];
        $datarray['parent'] = $params['parent'];
        $datarray['source_name'] = $params['source_name'];
        $datarray['source_link'] = $params['source_link'];
        $datarray['source_photo'] = $params['source_photo'];
        $datarray['uid'] = $params['uid'];
        $datarray['username'] = $params['to_name'];
        $datarray['hsitelink'] = $hsitelink;
        $datarray['tsitelink'] = $tsitelink;
        $datarray['hitemlink'] = '<a href="' . $itemlink . '">' . $itemlink . '</a>';
        $datarray['titemlink'] = $itemlink;
        $datarray['thanks'] = $thanks;
        $datarray['site_admin'] = $site_admin;
        $datarray['title'] = stripslashes($title);
        $datarray['htmlversion'] = $htmlversion;
        $datarray['textversion'] = $textversion;
        $datarray['subject'] = $subject;
        $datarray['headers'] = $additional_mail_header;
        call_hooks('enotify_mail', $datarray);
        // load the template for private message notifications
        $tpl = get_markup_template('email_notify_html.tpl');
        $email_html_body = replace_macros($tpl, array('$banner' => $datarray['banner'], '$product' => $datarray['product'], '$preamble' => $datarray['preamble'], '$sitename' => $datarray['sitename'], '$siteurl' => $datarray['siteurl'], '$source_name' => $datarray['source_name'], '$source_link' => $datarray['source_link'], '$source_photo' => $datarray['source_photo'], '$username' => $datarray['to_name'], '$hsitelink' => $datarray['hsitelink'], '$hitemlink' => $datarray['hitemlink'], '$thanks' => $datarray['thanks'], '$site_admin' => $datarray['site_admin'], '$title' => $datarray['title'], '$htmlversion' => $datarray['htmlversion']));
        // load the template for private message notifications
        $tpl = get_markup_template('email_notify_text.tpl');
        $email_text_body = replace_macros($tpl, array('$banner' => $datarray['banner'], '$product' => $datarray['product'], '$preamble' => $datarray['preamble'], '$sitename' => $datarray['sitename'], '$siteurl' => $datarray['siteurl'], '$source_name' => $datarray['source_name'], '$source_link' => $datarray['source_link'], '$source_photo' => $datarray['source_photo'], '$username' => $datarray['to_name'], '$tsitelink' => $datarray['tsitelink'], '$titemlink' => $datarray['titemlink'], '$thanks' => $datarray['thanks'], '$site_admin' => $datarray['site_admin'], '$title' => $datarray['title'], '$textversion' => $datarray['textversion']));
        //		logger('text: ' . $email_text_body);
        // use the EmailNotification library to send the message
        enotify::send(array('fromName' => $sender_name, 'fromEmail' => $sender_email, 'replyTo' => $sender_email, 'toEmail' => $params['to_email'], 'messageSubject' => $datarray['subject'], 'htmlVersion' => $email_html_body, 'textVersion' => $email_text_body, 'additionalMailHeader' => $datarray['headers']));
    }
    pop_lang();
}
开发者ID:robhell,项目名称:friendica,代码行数:101,代码来源:enotify.php

示例8: check_config

function check_config(&$a)
{
    $build = get_config('system', 'db_version');
    if (!intval($build)) {
        $build = set_config('system', 'db_version', DB_UPDATE_VERSION);
    }
    $saved = get_config('system', 'urlverify');
    if (!$saved) {
        set_config('system', 'urlverify', bin2hex(z_root()));
    }
    if ($saved && $saved != bin2hex(z_root())) {
        // our URL changed. Do something.
        $oldurl = hex2bin($saved);
        logger('Baseurl changed!');
        $oldhost = substr($oldurl, strpos($oldurl, '//') + 2);
        $host = substr(z_root(), strpos(z_root(), '//') + 2);
        $is_ip_addr = preg_match("/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\$/", $host) ? true : false;
        $was_ip_addr = preg_match("/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\$/", $oldhost) ? true : false;
        // only change the url to an ip address if it was already an ip and not a dns name
        if (!$is_ip_addr || $is_ip_addr && $was_ip_addr) {
            fix_system_urls($oldurl, z_root());
            set_config('system', 'urlverify', bin2hex(z_root()));
        } else {
            logger('Attempt to change baseurl from a DNS name to an IP address was refused.');
        }
    }
    // This will actually set the url to the one stored in .htconfig, and ignore what
    // we're passing - unless we are installing and it has never been set.
    App::set_baseurl(z_root());
    // Make sure each site has a system channel.  This is now created on install
    // so we just need to keep this around a couple of weeks until the hubs that
    // already exist have one
    $syschan_exists = get_sys_channel();
    if (!$syschan_exists) {
        create_sys_channel();
    }
    if ($build != DB_UPDATE_VERSION) {
        $stored = intval($build);
        if (!$stored) {
            logger('Critical: check_config unable to determine database schema version');
            return;
        }
        $current = intval(DB_UPDATE_VERSION);
        if ($stored < $current && file_exists('install/update.php')) {
            load_config('database');
            // We're reporting a different version than what is currently installed.
            // Run any existing update scripts to bring the database up to current.
            require_once 'install/update.php';
            // make sure that boot.php and update.php are the same release, we might be
            // updating right this very second and the correct version of the update.php
            // file may not be here yet. This can happen on a very busy site.
            if (DB_UPDATE_VERSION == UPDATE_VERSION) {
                for ($x = $stored; $x < $current; $x++) {
                    if (function_exists('update_r' . $x)) {
                        // There could be a lot of processes running or about to run.
                        // We want exactly one process to run the update command.
                        // So store the fact that we're taking responsibility
                        // after first checking to see if somebody else already has.
                        // If the update fails or times-out completely you may need to
                        // delete the config entry to try again.
                        if (get_config('database', 'update_r' . $x)) {
                            break;
                        }
                        set_config('database', 'update_r' . $x, '1');
                        // call the specific update
                        $func = 'update_r' . $x;
                        $retval = $func();
                        if ($retval) {
                            // Prevent sending hundreds of thousands of emails by creating
                            // a lockfile.
                            $lockfile = 'store/[data]/mailsent';
                            if (file_exists($lockfile) && filemtime($lockfile) > time() - 86400) {
                                return;
                            }
                            @unlink($lockfile);
                            //send the administrator an e-mail
                            file_put_contents($lockfile, $x);
                            $r = q("select account_language from account where account_email = '%s' limit 1", dbesc(App::$config['system']['admin_email']));
                            push_lang($r ? $r[0]['account_language'] : 'en');
                            $email_tpl = get_intltext_template("update_fail_eml.tpl");
                            $email_msg = replace_macros($email_tpl, array('$sitename' => App::$config['system']['sitename'], '$siteurl' => z_root(), '$update' => $x, '$error' => sprintf(t('Update %s failed. See error logs.'), $x)));
                            $subject = email_header_encode(sprintf(t('Update Error at %s'), z_root()));
                            mail(App::$config['system']['admin_email'], $subject, $email_msg, 'From: Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
                            //try the logger
                            logger('CRITICAL: Update Failed: ' . $x);
                            pop_lang();
                        } else {
                            set_config('database', 'update_r' . $x, 'success');
                        }
                    }
                }
                set_config('system', 'db_version', DB_UPDATE_VERSION);
            }
        }
    }
    /**
     *
     * Synchronise plugins:
     *
     * App::$config['system']['addon'] contains a comma-separated list of names
//.........这里部分代码省略.........
开发者ID:einervonvielen,项目名称:hubzilla,代码行数:101,代码来源:boot.php

示例9: account_allow

/**
 * @brief Allows a user registration.
 *
 * @param string $hash
 * @return array|boolean
 */
function account_allow($hash)
{
    $ret = array('success' => false);
    $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($hash));
    if (!$register) {
        return $ret;
    }
    $account = q("SELECT * FROM account WHERE account_id = %d LIMIT 1", intval($register[0]['uid']));
    if (!$account) {
        return $ret;
    }
    $r = q("DELETE FROM register WHERE hash = '%s'", dbesc($register[0]['hash']));
    $r = q("update account set account_flags = (account_flags & ~%d) where (account_flags & %d)>0 and account_id = %d", intval(ACCOUNT_BLOCKED), intval(ACCOUNT_BLOCKED), intval($register[0]['uid']));
    $r = q("update account set account_flags = (account_flags & ~%d) where (account_flags & %d)>0 and account_id = %d", intval(ACCOUNT_PENDING), intval(ACCOUNT_PENDING), intval($register[0]['uid']));
    push_lang($register[0]['lang']);
    $email_tpl = get_intltext_template("register_open_eml.tpl");
    $email_msg = replace_macros($email_tpl, array('$sitename' => get_config('system', 'sitename'), '$siteurl' => z_root(), '$username' => $account[0]['account_email'], '$email' => $account[0]['account_email'], '$password' => '', '$uid' => $account[0]['account_id']));
    $res = z_mail(['toEmail' => $account[0]['account_email'], 'messageSubject' => sprintf(t('Registration details for %s'), get_config('system', 'sitename')), 'textVersion' => $email_msg]);
    pop_lang();
    if (get_config('system', 'auto_channel_create') || get_config('system', 'server_role') === 'basic') {
        auto_channel_create($register[0]['uid']);
    }
    if ($res) {
        info(t('Account approved.') . EOL);
        return true;
    }
}
开发者ID:phellmes,项目名称:hubzilla,代码行数:33,代码来源:account.php

示例10: local_delivery


//.........这里部分代码省略.........
        $r = dbq("INSERT INTO `mail` (`" . implode("`, `", array_keys($msg)) . "`) VALUES ('" . implode("', '", array_values($msg)) . "')");
        // send email notification if requested.
        require_once 'bbcode.php';
        if ($importer['notify-flags'] & NOTIFY_MAIL) {
            push_lang($importer['language']);
            // name of the automated email sender
            $msg['notificationfromname'] = t('Administrator');
            // noreply address to send from
            $msg['notificationfromemail'] = t('noreply') . '@' . $a->get_hostname();
            // text version
            // process the message body to display properly in text mode
            // 		1) substitute a \n character for the "\" then "n", so it behaves properly (it doesn't come in as a \n character)
            //		2) remove escape slashes
            //		3) decode any bbcode from the message editor
            //		4) decode any encoded html tags
            //		5) remove html tags
            $msg['textversion'] = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n", $msg['body']))), ENT_QUOTES, 'UTF-8'));
            // html version
            // process the message body to display properly in text mode
            // 		1) substitute a <br /> tag for the "\" then "n", so it behaves properly (it doesn't come in as a \n character)
            //		2) remove escape slashes
            //		3) decode any bbcode from the message editor
            //		4) decode any encoded html tags
            $msg['htmlversion'] = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n\\n", "\\n"), "<br />\n", $msg['body']))));
            // load the template for private message notifications
            $tpl = get_intltext_template('mail_received_html_body_eml.tpl');
            $email_html_body_tpl = replace_macros($tpl, array('$username' => $importer['username'], '$siteName' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$thumb' => $importer['thumb'], '$email' => $importer['email'], '$url' => $importer['url'], '$from' => $msg['from-name'], '$title' => stripslashes($msg['title']), '$htmlversion' => $msg['htmlversion'], '$mimeboundary' => $msg['mimeboundary'], '$hostname' => $a->get_hostname()));
            // load the template for private message notifications
            $tpl = get_intltext_template('mail_received_text_body_eml.tpl');
            $email_text_body_tpl = replace_macros($tpl, array('$username' => $importer['username'], '$siteName' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$thumb' => $importer['thumb'], '$email' => $importer['email'], '$url' => $importer['url'], '$from' => $msg['from-name'], '$title' => stripslashes($msg['title']), '$textversion' => $msg['textversion'], '$mimeboundary' => $msg['mimeboundary'], '$hostname' => $a->get_hostname()));
            // use the EmailNotification library to send the message
            require_once "include/EmailNotification.php";
            EmailNotification::sendTextHtmlEmail($msg['notificationfromname'], $msg['notificationfromemail'], $msg['notificationfromemail'], $importer['email'], t('New mail received at ') . $a->config['sitename'], $email_html_body_tpl, $email_text_body_tpl);
            pop_lang();
        }
        return 0;
        // NOTREACHED
    }
    logger('local_delivery: feed item count = ' . $feed->get_item_quantity());
    // process any deleted entries
    $del_entries = $feed->get_feed_tags(NAMESPACE_TOMB, 'deleted-entry');
    if (is_array($del_entries) && count($del_entries)) {
        foreach ($del_entries as $dentry) {
            $deleted = false;
            if (isset($dentry['attribs']['']['ref'])) {
                $uri = $dentry['attribs']['']['ref'];
                $deleted = true;
                if (isset($dentry['attribs']['']['when'])) {
                    $when = $dentry['attribs']['']['when'];
                    $when = datetime_convert('UTC', 'UTC', $when, 'Y-m-d H:i:s');
                } else {
                    $when = datetime_convert('UTC', 'UTC', 'now', 'Y-m-d H:i:s');
                }
            }
            if ($deleted) {
                $r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join contact on `item`.`contact-id` = `contact`.`id`\n\t\t\t\t\tWHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d LIMIT 1", dbesc($uri), intval($importer['importer_uid']), intval($importer['id']));
                if (count($r)) {
                    $item = $r[0];
                    if ($item['deleted']) {
                        continue;
                    }
                    logger('local_delivery: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG);
                    if ($item['verb'] === ACTIVITY_TAG && $item['object-type'] === ACTVITY_OBJ_TAGTERM) {
                        $xo = parse_xml_string($item['object'], false);
                        $xt = parse_xml_string($item['target'], false);
                        if ($xt->type === ACTIVITY_OBJ_NOTE) {
开发者ID:ryivhnn,项目名称:friendica,代码行数:67,代码来源:items.php

示例11: dfrn_confirm_post


//.........这里部分代码省略.........
            $message = t('Unable to set your contact credentials on our system.');
            xml_status(3, $message);
        }
        // It's possible that the other person also requested friendship.
        // If it is a duplex relationship, ditch the issued-id if one exists.
        if ($duplex) {
            $r = q("UPDATE `contact` SET `issued-id` = '' WHERE `id` = %d LIMIT 1", intval($dfrn_record));
        }
        // We're good but now we have to scrape the profile photo and send notifications.
        $r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1", intval($dfrn_record));
        if (count($r)) {
            $photo = $r[0]['photo'];
        } else {
            $photo = $a->get_baseurl() . '/images/person-175.jpg';
        }
        require_once "include/Photo.php";
        $photos = import_profile_photo($photo, $local_uid, $dfrn_record);
        logger('dfrn_confirm: request - photos imported');
        $new_relation = CONTACT_IS_SHARING;
        if ($relation == CONTACT_IS_FOLLOWER || $duplex) {
            $new_relation = CONTACT_IS_FRIEND;
        }
        if ($relation == CONTACT_IS_FOLLOWER && $duplex) {
            $duplex = 0;
        }
        $r = q("UPDATE `contact` SET \n\t\t\t`photo` = '%s', \n\t\t\t`thumb` = '%s', \n\t\t\t`micro` = '%s',\n\t\t\t`rel` = %d, \n\t\t\t`name-date` = '%s', \n\t\t\t`uri-date` = '%s', \n\t\t\t`avatar-date` = '%s', \n\t\t\t`blocked` = 0, \n\t\t\t`pending` = 0,\n\t\t\t`duplex` = %d, \n\t\t\t`forum` = %d,\n\t\t\t`prv` = %d,\n\t\t\t`network` = '%s' WHERE `id` = %d LIMIT 1\n\t\t", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), intval($new_relation), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($duplex), intval($forum), intval($prv), dbesc(NETWORK_DFRN), intval($dfrn_record));
        if ($r === false) {
            // indicates schema is messed up or total db failure
            $message = t('Unable to update your contact profile details on our system');
            xml_status(3, $message);
        }
        // Otherwise everything seems to have worked and we are almost done. Yay!
        // Send an email notification
        logger('dfrn_confirm: request: info updated');
        $r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`\n\t\t\tWHERE `contact`.`id` = %d LIMIT 1", intval($dfrn_record));
        if (count($r)) {
            $combined = $r[0];
        }
        if (count($r) && $r[0]['notify-flags'] & NOTIFY_CONFIRM) {
            push_lang($r[0]['language']);
            $tpl = $new_relation == CONTACT_IS_FRIEND ? get_intltext_template('friend_complete_eml.tpl') : get_intltext_template('intro_complete_eml.tpl');
            $email_tpl = replace_macros($tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => $r[0]['username'], '$email' => $r[0]['email'], '$fn' => $r[0]['name'], '$dfrn_url' => $r[0]['url'], '$uid' => $newuid));
            require_once 'include/email.php';
            $res = mail($r[0]['email'], email_header_encode(sprintf(t("Connection accepted at %s"), $a->config['sitename']), 'UTF-8'), $email_tpl, 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
            if (!$res) {
                // pointless throwing an error here and confusing the person at the other end of the wire.
            }
            pop_lang();
        }
        // Send a new friend post if we are allowed to...
        if ($page && intval(get_pconfig($local_uid, 'system', 'post_joingroup'))) {
            $r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", intval($local_uid));
            if (count($r) && $r[0]['hide-friends'] == 0) {
                require_once 'include/items.php';
                $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($local_uid));
                if (count($self)) {
                    $arr = array();
                    $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid);
                    $arr['uid'] = $local_uid;
                    $arr['contact-id'] = $self[0]['id'];
                    $arr['wall'] = 1;
                    $arr['type'] = 'wall';
                    $arr['gravity'] = 0;
                    $arr['origin'] = 1;
                    $arr['author-name'] = $arr['owner-name'] = $self[0]['name'];
                    $arr['author-link'] = $arr['owner-link'] = $self[0]['url'];
                    $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb'];
                    $A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]';
                    $APhoto = '[url=' . $self[0]['url'] . ']' . '[img]' . $self[0]['thumb'] . '[/img][/url]';
                    $B = '[url=' . $combined['url'] . ']' . $combined['name'] . '[/url]';
                    $BPhoto = '[url=' . $combined['url'] . ']' . '[img]' . $combined['thumb'] . '[/img][/url]';
                    $arr['verb'] = ACTIVITY_JOIN;
                    $arr['object-type'] = ACTIVITY_OBJ_GROUP;
                    $arr['body'] = sprintf(t('%1$s has joined %2$s'), $A, $B) . "\n\n\n" . $BPhoto;
                    $arr['object'] = '<object><type>' . ACTIVITY_OBJ_GROUP . '</type><title>' . $combined['name'] . '</title>' . '<id>' . $combined['url'] . '/' . $combined['name'] . '</id>';
                    $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $combined['url'] . '" />' . "\n");
                    $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $combined['thumb'] . '" />' . "\n");
                    $arr['object'] .= '</link></object>' . "\n";
                    $arr['last-child'] = 1;
                    $arr['allow_cid'] = $user[0]['allow_cid'];
                    $arr['allow_gid'] = $user[0]['allow_gid'];
                    $arr['deny_cid'] = $user[0]['deny_cid'];
                    $arr['deny_gid'] = $user[0]['deny_gid'];
                    $i = item_store($arr);
                    if ($i) {
                        proc_run('php', "include/notifier.php", "activity", "{$i}");
                    }
                }
            }
        }
        xml_status(0);
        // Success
        return;
        // NOTREACHED
        ////////////////////// End of this scenario ///////////////////////////////////////////////
    }
    // somebody arrived here by mistake or they are fishing. Send them to the homepage.
    goaway(z_root());
    // NOTREACHED
}
开发者ID:ridcully,项目名称:friendica,代码行数:101,代码来源:dfrn_confirm.php

示例12: item_post


//.........这里部分代码省略.........
    $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($datarray['uri']));
    if (count($r)) {
        $post_id = $r[0]['id'];
        logger('mod_item: saved item ' . $post_id);
        if ($parent) {
            // This item is the last leaf and gets the comment box, clear any ancestors
            $r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent` = %d ", dbesc(datetime_convert()), intval($parent));
            // Inherit ACL's from the parent item.
            $r = q("UPDATE `item` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `private` = %d\n\t\t\t\tWHERE `id` = %d LIMIT 1", dbesc($parent_item['allow_cid']), dbesc($parent_item['allow_gid']), dbesc($parent_item['deny_cid']), dbesc($parent_item['deny_gid']), intval($parent_item['private']), intval($post_id));
            // Send a notification email to the conversation owner, unless the owner is me and I wrote this item
            if ($user['notify-flags'] & NOTIFY_COMMENT && $contact_record != $author) {
                push_lang($user['language']);
                require_once 'bbcode.php';
                $from = $author['name'];
                // name of the automated email sender
                $msg['notificationfromname'] = stripslashes($datarray['author-name']);
                // noreply address to send from
                $msg['notificationfromemail'] = t('noreply') . '@' . $a->get_hostname();
                // text version
                // process the message body to display properly in text mode
                $msg['textversion'] = html_entity_decode(strip_tags(bbcode(stripslashes($datarray['body']))), ENT_QUOTES, 'UTF-8');
                // html version
                // process the message body to display properly in text mode
                $msg['htmlversion'] = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n\\n", "\\n"), "<br />\n", $datarray['body']))));
                // load the template for private message notifications
                $tpl = get_intltext_template('cmnt_received_html_body_eml.tpl');
                $email_html_body_tpl = replace_macros($tpl, array('$username' => $user['username'], '$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$thumb' => $author['thumb'], '$email' => $importer['email'], '$url' => $author['url'], '$from' => $from, '$body' => $msg['htmlversion'], '$display' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id));
                // load the template for private message notifications
                $tpl = get_intltext_template('cmnt_received_text_body_eml.tpl');
                $email_text_body_tpl = replace_macros($tpl, array('$username' => $user['username'], '$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$thumb' => $author['thumb'], '$email' => $importer['email'], '$url' => $author['url'], '$from' => $from, '$body' => $msg['textversion'], '$display' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id));
                // use the EmailNotification library to send the message
                require_once "include/EmailNotification.php";
                EmailNotification::sendTextHtmlEmail($msg['notificationfromname'], t("Administrator@") . $a->get_hostname(), t("noreply") . '@' . $a->get_hostname(), $user['email'], sprintf(t('%s commented on an item at %s'), $from, $a->config['sitename']), $email_html_body_tpl, $email_text_body_tpl);
                pop_lang();
            }
            // We won't be able to sign Diaspora comments for authenticated visitors - we don't have their private key
            if ($self) {
                require_once 'include/bb2diaspora.php';
                $signed_body = html_entity_decode(bb2diaspora($datarray['body']));
                $myaddr = $a->user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(), '://') + 3);
                if ($datarray['verb'] === ACTIVITY_LIKE) {
                    $signed_text = $datarray['guid'] . ';' . 'Post' . ';' . $parent_item['guid'] . ';' . 'true' . ';' . $myaddr;
                } else {
                    $signed_text = $datarray['guid'] . ';' . $parent_item['guid'] . ';' . $signed_body . ';' . $myaddr;
                }
                $authorsig = base64_encode(rsa_sign($signed_text, $a->user['prvkey'], 'sha256'));
                q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", intval($post_id), dbesc($signed_text), dbesc(base64_encode($authorsig)), dbesc($myaddr));
            }
        } else {
            $parent = $post_id;
            // let me know if somebody did a wall-to-wall post on my profile
            if ($user['notify-flags'] & NOTIFY_WALL && $contact_record != $author) {
                push_lang($user['language']);
                require_once 'bbcode.php';
                $from = $author['name'];
                // name of the automated email sender
                $msg['notificationfromname'] = $from;
                // noreply address to send from
                $msg['notificationfromemail'] = t('noreply') . '@' . $a->get_hostname();
                // text version
                // process the message body to display properly in text mode
                $msg['textversion'] = html_entity_decode(strip_tags(bbcode(stripslashes($datarray['body']))), ENT_QUOTES, 'UTF-8');
                // html version
                // process the message body to display properly in text mode
                $msg['htmlversion'] = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n\\n", "\\n"), "<br />\n", $datarray['body']))));
                // load the template for private message notifications
开发者ID:ryivhnn,项目名称:friendica,代码行数:67,代码来源:item.php

示例13: notification

function notification($params)
{
    logger('notification: entry', LOGGER_DEBUG);
    $a = get_app();
    $banner = t('Friendica Notification');
    $product = FRIENDICA_PLATFORM;
    $siteurl = z_path();
    $thanks = t('Thank You,');
    $sitename = get_config('config', 'sitename');
    $site_admin = sprintf(t('%s Administrator'), $sitename);
    $sender_name = $product;
    $sender_email = t('noreply') . '@' . $a->get_hostname();
    if (array_key_exists('item', $params)) {
        $title = $params['item']['title'];
        $body = $params['item']['body'];
    } else {
        $title = $body = '';
    }
    if ($params['type'] == NOTIFY_MAIL) {
        $subject = sprintf(t('New mail received at %s'), $sitename);
        $preamble = sprintf(t('%s sent you a new private message at %s.'), $params['source_name'], $sitename);
        $sitelink = t('Please visit %s to view and/or reply to your private messages.');
        $tsitelink = sprintf($sitelink, $siteurl . '/message');
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '/message">' . $sitename . '</a>');
        $itemlink = '';
    }
    if ($params['type'] == NOTIFY_COMMENT) {
        $subject = sprintf(t('%s commented on an item at %s'), $params['source_name'], $sitename);
        $preamble = sprintf(t('%s commented on an item/conversation you have been following.'), $params['source_name']);
        $sitelink = t('Please visit %s to view and/or reply to the conversation.');
        $tsitelink = sprintf($sitelink, $siteurl);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
        $itemlink = $params['link'];
    }
    if ($params['type'] == NOTIFY_WALL) {
        $preamble = $subject = sprintf(t('%s posted to your profile wall at %s'), $params['source_name'], $sitename);
        $sitelink = t('Please visit %s to view and/or reply to the conversation.');
        $tsitelink = sprintf($sitelink, $siteurl);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
        $itemlink = $params['link'];
    }
    if ($params['type'] == NOTIFY_TAGSELF) {
        $preamble = $subject = sprintf(t('%s tagged you at %s'), $params['source_name'], $sitename);
        $sitelink = t('Please visit %s to view and/or reply to the conversation.');
        $tsitelink = sprintf($sitelink, $siteurl);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
        $itemlink = $params['link'];
    }
    if ($params['type'] == NOTIFY_TAGSHARE) {
        $preamble = $subject = sprintf(t('%s tagged your post at %s'), $params['source_name'], $sitename);
        $sitelink = t('Please visit %s to view and/or reply to the conversation.');
        $tsitelink = sprintf($sitelink, $siteurl);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
        $itemlink = $params['link'];
    }
    if ($params['type'] == NOTIFY_INTRO) {
        $subject = sprintf(t('Introduction received at %s'), $sitename);
        $preamble = sprintf(t('You\'ve received an introduction from \'%s\' at %s'), $params['source_name'], $sitename);
        $body = sprintf(t('You may visit their profile at %s'), $params['source_link']);
        $sitelink = t('Please visit %s to approve or reject the introduction.');
        $tsitelink = sprintf($sitelink, $siteurl);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
        $itemlink = $params['link'];
    }
    if ($params['type'] == NOTIFY_SUGGEST) {
        $subject = sprintf(t('Friend suggestion received at %s'), $sitename);
        $preamble = sprintf(t('You\'ve received a friend suggestion from \'%s\' at %s'), $params['source_name'], $sitename);
        $body = t('Name:') . ' ' . $params['item']['name'] . "\n";
        $body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n";
        $body .= sprintf(t('You may visit their profile at %s'), $params['item']['url']);
        $sitelink = t('Please visit %s to approve or reject the suggestion.');
        $tsitelink = sprintf($sitelink, $siteurl);
        $hsitelink = sprintf($sitelink, '<a href="' . $siteurl . '">' . $sitename . '</a>');
        $itemlink = $params['link'];
    }
    if ($params['type'] == NOTIFY_CONFIRM) {
    }
    // TODO - create notification entry in DB
    // send email notification if notification preferences permit
    require_once 'bbcode.php';
    if (intval($params['notify_flags']) & intval($params['type'])) {
        logger('notification: sending notification email');
        push_lang($params['language']);
        $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n", $body))), ENT_QUOTES, 'UTF-8'));
        $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n\\n", "\\n"), "<br />\n", $body))));
        // load the template for private message notifications
        $tpl = get_markup_template('email_notify_html.tpl');
        $email_html_body = replace_macros($tpl, array('$banner' => $banner, '$product' => $product, '$preamble' => $preamble, '$sitename' => $sitename, '$siteurl' => $siteurl, '$source_name' => $parama['source_name'], '$source_link' => $params['source_link'], '$source_photo' => $params['source_photo'], '$username' => $params['to_name'], '$hsitelink' => $hsitelink, '$itemlink' => '<a href="' . $itemlink . '">' . $itemlink . '</a>', '$thanks' => $thanks, '$site_admin' => $site_admin, '$title' => stripslashes($title), '$htmlversion' => $htmlversion));
        // load the template for private message notifications
        $tpl = get_markup_template('email_notify_text.tpl');
        $email_text_body = replace_macros($tpl, array('$banner' => $banner, '$product' => $product, '$preamble' => $preamble, '$sitename' => $sitename, '$siteurl' => $siteurl, '$source_name' => $parama['source_name'], '$source_link' => $params['source_link'], '$source_photo' => $params['source_photo'], '$username' => $params['to_name'], '$tsitelink' => $tsitelink, '$itemlink' => $itemlink, '$thanks' => $thanks, '$site_admin' => $site_admin, '$title' => stripslashes($title), '$textversion' => $textversion));
        //		logger('text: ' . $email_text_body);
        // use the EmailNotification library to send the message
        enotify::send(array('fromName' => $sender_name, 'fromEmail' => $sender_email, 'replyTo' => $sender_email, 'toEmail' => $params['to_email'], 'messageSubject' => $subject, 'htmlVersion' => $email_html_body, 'textVersion' => $email_text_body));
        pop_lang();
    }
}
开发者ID:nextgensh,项目名称:friendica,代码行数:97,代码来源:enotify.php

示例14: register_post

 function register_post(&$a)
 {
     global $lang;
     $verified = 0;
     $blocked = 1;
     $arr = array('post' => $_POST);
     call_hooks('register_post', $arr);
     $max_dailies = intval(get_config('system', 'max_daily_registrations'));
     if ($max_dailes) {
         $r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day");
         if ($r && $r[0]['total'] >= $max_dailies) {
             return;
         }
     }
     switch ($a->config['register_policy']) {
         case REGISTER_OPEN:
             $blocked = 0;
             $verified = 1;
             break;
         case REGISTER_APPROVE:
             $blocked = 1;
             $verified = 0;
             break;
         default:
         case REGISTER_CLOSED:
             if (!x($_SESSION, 'authenticated') && !x($_SESSION, 'administrator')) {
                 notice(t('Permission denied.') . EOL);
                 return;
             }
             $blocked = 1;
             $verified = 0;
             break;
     }
     require_once 'include/user.php';
     $arr = $_POST;
     $arr['blocked'] = $blocked;
     $arr['verified'] = $verified;
     $result = create_user($arr);
     if (!$result['success']) {
         notice($result['message']);
         return;
     }
     $user = $result['user'];
     if ($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) {
         $url = $a->get_baseurl() . '/profile/' . $user['nickname'];
         proc_run('php', "include/directory.php", "{$url}");
     }
     $using_invites = get_config('system', 'invitation_only');
     $num_invites = get_config('system', 'number_invites');
     $invite_id = x($_POST, 'invite_id') ? notags(trim($_POST['invite_id'])) : '';
     if ($a->config['register_policy'] == REGISTER_OPEN) {
         if ($using_invites && $invite_id) {
             q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
             set_pconfig($user['uid'], 'system', 'invites_remaining', $num_invites);
         }
         $email_tpl = get_intltext_template("register_open_eml.tpl");
         $email_tpl = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => $user['username'], '$email' => $user['email'], '$password' => $result['password'], '$uid' => $user['uid']));
         $res = mail($user['email'], sprintf(t('Registration details for %s'), $a->config['sitename']), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
         if ($res) {
             info(t('Registration successful. Please check your email for further instructions.') . EOL);
             goaway(z_root());
         } else {
             notice(t('Failed to send email message. Here is the message that failed.') . $email_tpl . EOL);
         }
     } elseif ($a->config['register_policy'] == REGISTER_APPROVE) {
         if (!strlen($a->config['admin_email'])) {
             notice(t('Your registration can not be processed.') . EOL);
             goaway(z_root());
         }
         $hash = random_string();
         $r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language` ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ", dbesc($hash), dbesc(datetime_convert()), intval($user['uid']), dbesc($result['password']), dbesc($lang));
         $r = q("SELECT `language` FROM `user` WHERE `email` = '%s' LIMIT 1", dbesc($a->config['admin_email']));
         if (count($r)) {
             push_lang($r[0]['language']);
         } else {
             push_lang('en');
         }
         if ($using_invites && $invite_id) {
             q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
             set_pconfig($user['uid'], 'system', 'invites_remaining', $num_invites);
         }
         $email_tpl = get_intltext_template("register_verify_eml.tpl");
         $email_tpl = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => $user['username'], '$email' => $user['email'], '$password' => $result['password'], '$uid' => $user['uid'], '$hash' => $hash));
         $res = mail($a->config['admin_email'], sprintf(t('Registration request at %s'), $a->config['sitename']), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
         pop_lang();
         if ($res) {
             info(t('Your registration is pending approval by the site owner.') . EOL);
             goaway(z_root());
         }
     }
     return;
 }
开发者ID:robhell,项目名称:friendica,代码行数:92,代码来源:register.php


注:本文中的pop_lang函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。